function person(name){
this.name1 = "His";
this.day = {};
this.day.time="kokok";
this.check = function(name){
for(var i in this) console.log(this["i"]);
if(this.name1===name) console.log("ready"+this.day.time);
};
}
var t= new person("His");
t.check("His");
Asked
Active
Viewed 21 times
0

jfriend00
- 683,504
- 96
- 985
- 979

Developer7
- 9
- 1
-
http://stackoverflow.com/questions/359732/why-is-it-considered-a-bad-practice-to-omit-curly-braces?lq=1 – Barmar May 07 '15 at 20:53
1 Answers
1
It needs to be:
console.log(this[i]);
instead of:
console.log(this["i"]);
You want to reference the variable i
, not a string "i"
.

jfriend00
- 683,504
- 96
- 985
- 979