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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -