I am currently building a mashup in Qlik Sense in JavaScript and jQuery. I have made some data selection and I have put them in a variable object :
var CurrentSelec = app1.selectionState().selections;
console.log(CurrentSelec);`
console.log(typeof CurrentSelec);
This is what I get on my browser console :

I'm trying to show the qSelected value in a Foreach :
I have tried with Javascript :
for(var index in CurrentSelec) {
console.log(index.qSelected);
}
I have tried with jQuery:
$.each(CurrentSelec, function(i, index) {
console.log(index.qSelected)
});
But my browser console do not show the log of my foreach.
Do you know how to properly make a foreach of an object and show its content on a browser console, please ?
Regards.
You can use the Object.keys() method, which returns an array of the keys in an object. Then we run that through an Array.forEach() method. for example
Object.keys(lunch).forEach(function (item) {
console.log(item); // key
console.log(lunch[item]); // value
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With