Last active
August 29, 2015 13:59
Javascript Beginner's series - Objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Reflection | |
//"typeof" does it for you | |
console.log(typeof flight.number); // 'number' | |
console.log(typeof flight.arrival); // 'object' | |
console.log(typeof flight.manifest); // 'undefined' | |
console.log(typeof flight.toString); // 'function' | |
console.log(typeof flight.constructor); // 'function' | |
/* | |
If you would like to access an object property and want the value of the child not the parent's, you can use "hasOwnProperty" | |
*/ | |
console.log(flight.hasOwnProperty('number')); // true | |
console.log(flight.hasOwnProperty('constructor')); // false | |
//How to delete an object property: | |
delete flight.arrival | |
console.log(flight); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment