jul097
4/30/2020 - 3:06 PM

Creating your own objects (Example)

function person(name,age,color){
  this.name = name;
  this.age = age;
  this.favColor = color;
}
var p1 = new person("John", 42, "green");
var p2 = new person("Amy", 21, "red");

document.write(p1.age); // Outputs 42
document.write(p2.name); // Outputs "Amy"