lecture16

lecture16 - PIC 40A Lecture 16: JavaScript Objects...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
PIC 40A Lecture 16: JavaScript Objects
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
JavaScript Objects •A n object is a collection of property - value pairs. • Every object is indirectly accessed through a variable holding an object reference to it. (A reference is like a pointer but no dereferencing needed) • Functions and arrays are objects and are referenced through variables!
Background image of page 2
Object Properties • Each property of an object is either a data property method property • Data properties can appear as – Primitive values (aka value types ) – Object references • Properties of an object can be added or removed anytime (not like C++)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Properties • are names of values so they are never declared • are accessed via the dot operator . – some properties are inherited (shared by all objects made from the same prototype) eg Number.NaN, Math.E – others are direct properties (not inherited from the prototype) eg var s = new String(“cool”); s.length; Here, the object reference held by s allows us to get the string's length property value
Background image of page 4
• create clones of existing objects (prototypes) by using the new operator followed by a call to a constructor method: eg var myObject = new Object(); var myDate = new Date();
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 21

lecture16 - PIC 40A Lecture 16: JavaScript Objects...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online