jeudi 30 avril 2015

Why is this Array.length if else check not working?

enter image description here

Obviously tagObjects is an array and has a length of 0. However it's still getting past that check and causes an error.

TypeError: Cannot read property 'length' of undefined

if (tagObjects != "empty" || tagObjects.length === 0) {
    for (var i = 0; i < tagObjects.tags.length; i++) {
        temp_tags.push(tagObjects[i].tags);
    }

    temp_tags.forEach(function(obj) {
        if (obj.selected) {
            if (vs.tags[map[obj.term]] != undefined) {
                vs.tags[map[obj.term]].selected = true;
            }
        }
    });
}

It's even getting past the string check!

enter image description here

Aucun commentaire:

Enregistrer un commentaire