CP476 Internet Computing Week 7 2 JS Objects
CP476 Internet Computing Week 7 2 JS Objects
• Demo11
• Note: (1) even if the getter is a method, do not use parentheses when
calling them; (2) get and set keywords can be used outside of classes
JavaScript - Object Prototypes
• We cannot add a new property to an existing object constructor from
outside of the object constructor.
function Person(first, last, age, eyeColor) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eyeColor;
}
Person.nationality = "English";
• Demo12
JavaScript - Map Objects
• A Map object holds key-value pairs where the keys can be any
datatype.
• Essential Map() Methods: