Created
July 26, 2019 20:50
-
-
Save fabriciofmsilva/ca5e57016397b176103fb678a9980a57 to your computer and use it in GitHub Desktop.
JavaScript 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
const NAME = Symbol(); | |
const person = { | |
[NAME]: 'Flavio' | |
}; | |
person[NAME]; //'Flavio' | |
const RUN = Symbol(); | |
person[RUN] = () => 'Person is running'; | |
console.log(person[RUN]()); //'Person is running' | |
person.surname = 'Copes'; | |
// for...in | |
for (const prop in person) { console.log(prop) } // surname | |
console.log(Object.keys(person)); // ["surname"] | |
console.log(Object.getOwnPropertyNames(person)); // ["surname"] | |
console.log(Object.getOwnPropertySymbols(person)); // [Symbol(), Symbol()] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment