Skip to content

Instantly share code, notes, and snippets.

@adilmezghouti
Last active August 29, 2015 13:59
Show Gist options
  • Save adilmezghouti/10690673 to your computer and use it in GitHub Desktop.
Save adilmezghouti/10690673 to your computer and use it in GitHub Desktop.
Javascript Beginner's series - Objects
//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