javascript - i just want to print the first value(name) from the array -


in below code trying print out first value (name) of array, doesn't work expect:

function person (name, age) {   this.name = name;   this.age = age; }// our person constructor   // can make array of people var family = new array(); family[0] = new person("alice", 40); family[1] = new person("bob", 42); family[2] = new person("michelle", 8); family[3] = new person("timmy", 6); // loop through our new array for(i = 0; <= family.length; i++) {   console.log( family[i].this.name);  } 

you using "this" keyword incorrectly. when access family[i] accessing instance of prototype in javascript. drop "this."


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -