I have some simple Javascript looping through an array of items (Tridion User Groups) to check if the user is a member of a specific group.
I can easily code around the issue shown below ( see && extensionGroup !== 'true') but I want to understand why the isArray = true is counted as a value in the array – any ideas?
The screenshot below demonstrates that the value extensionGroups has been set thus
var extensionGroups = ["NotEvenARealGroup", "Author", "ExampleGroupAfterOneUserIsActuallyIn"];
but returns the isArray value as a 4th value?
updated to show images a little clearer


You’re using
for into iterate an array; don’t do that. Usefor(orforEach):The reason this fails is because
for inis used to iterate over an object’s properties in JavaScript. Iterating over an array in this way means you get anything else assigned to it, such as this property orlength.And if you’re able to use
Array#forEach, it’s probably most appropriate here: