- Constructors are actually their own type of class
- A public method can return a private variable along with other private methods
- Use "var" in a class to make the variable private and "this" to make it public
- this.age = age; (public)
var bankBalance = 7500; (private) - Inheritance is useful when 2 classes share similar properties
- "Child".prototype = new "Parent"()
- If you want a method to work with all the members of a class use "prototype"
className.prototype.newMethod = function() { statements; };
- "Typeof" allows you to determine the type of a variable
- "hasOwnProperty" returns true or false whether or not an object has a certain property
- This is useful for if else statements
- "for in loops" are simplified for loops that look like this
for (var properties in nyc){ console.log(nyc[properties]); }
bracket notations can be used to print the values of an object
Tuesday, April 22, 2014
JavaScript Objects II Notes
Subscribe to:
Post Comments (Atom)
Good notes! I'm still looking for a deeper understanding of how inheritance works in JavaScript. For now, I'm going to get comfortable using it, then I'll "look under the hood" more. I think that is a good approach for all of us.
ReplyDelete