In my measure dimension each element has a numeric attribute called Editable which will either be 0 or 1.
I retrieve these dimension elements using $tm1Ui.dimensionElements and get all the elements as expected in the response array, and if the attribute is 1 it is set as such in the response array. But if the attribute is 0 it is simply not defined in the response.
var editable = response[idx].Attributes['Editable']);
if (editable) {
//do some action
}
The above code will work because the attribute value 0 will be returned as undefined and 1 will be returned as "1"(string), thus the boolean evaluation will behave as expected with 1 evaluating as true and 0 evaluating as false. If $tm1Ui.dimensionElements ever changes and returns "0"(string) for the attribute value 0 then the variable editable will always evaluate as true in a boolean context.
To safeguard against this I do:
var editable = 1 == response[idx].Attributes['Editable']);
I guess not everyone is aware of this trap though.