Last active
June 26, 2018 22:16
-
-
Save colevandersWands/69ac68ffd4c8b2da53a8297f2937d74c to your computer and use it in GitHub Desktop.
brackets and dots
This file contains 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
// an example to learn about dots and brackets | |
// below are 6 test cases that work | |
// try writing some that break, find out what's happening | |
// https://goo.gl/ezGgh5 - pythontutor | |
var og = {first: 'fifty', last: 'cent'}; | |
var curtis = 'first'; | |
var jackson = 'last'; | |
console.log(og.first); | |
console.log(og.last); | |
console.log(og[curtis]); | |
console.log(og[jackson]); | |
console.log(og["first"]); | |
console.log(og["last"]); | |
console.log(og[0]); | |
console.log(og[1]); | |
// -------------------------------- | |
var person = { | |
name: 'John', | |
lastName: 'Smith', | |
age: 32, | |
key: 0 | |
}; | |
for (let key in person){ | |
console.log(person[key]); | |
console.log(key) | |
console.log(person.key) | |
console.log("--------") | |
} | |
for (let mike in person){ | |
console.log(person[mike]); | |
console.log(mike) | |
console.log(person.mike) | |
console.log("--------") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment