How to get the property name or index number having false value

时间:2015-04-23 05:14:52

标签: javascript arrays object

I have a object and I am trying to get the those value have false value but not able to get the value of those property who have array or objects.

Below is my code

var obj  = [{
                    "class": true,
                    "room": false,
                    "students": [
                        true,
                        false
                    ],
                    "result": {
                        "first": "pass",
                        "second": "fail",
                        "third":false
                    }
                }];


    for(var i = 0; i<obj.length; i++){

        for(name in obj[i]){
            //console.log(obj[i].hasOwnProperty(name))

            if(!obj[i][name]){
                console.log(name)
            }

        }
    }

currently result coming only "room" / required result is "room",1, "third"

0 个答案:

没有答案