Skip to content

Instantly share code, notes, and snippets.

@keevitaja
Last active December 28, 2019 15:47
Show Gist options
  • Save keevitaja/127dc38f01b7e856ffa2f60ad47ea0a3 to your computer and use it in GitHub Desktop.
Save keevitaja/127dc38f01b7e856ffa2f60ad47ea0a3 to your computer and use it in GitHub Desktop.
const print = obj => {
for (const key in obj) {
console.log(obj[key])
}
}
const num = {}
num[5] = 5
num[2] = 2
num[7] = 7
num[1] = 1
print(num)
console.log('\n\n')
const str = {}
str['h'] = 'h'
str['b'] = 'b'
str['z'] = 'z'
str['a'] = 'a'
print(str)
// outputs:
//
// 1
// 2
// 5
// 7
//
// h
// b
// z
// a
//
// is this behevior guaranteed?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment