Skip to content

Instantly share code, notes, and snippets.

@afrontend
Created August 30, 2017 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afrontend/82b60417519a6ef4982adedbdb989649 to your computer and use it in GitHub Desktop.
Save afrontend/82b60417519a6ef4982adedbdb989649 to your computer and use it in GitHub Desktop.
a = {}
b = new Object()
typeof(a)
typeof(b)
a
b
a['name'] = 'apple'
a['color'] = 'red'
a
Object.entries(a)
Object.keys(a)
Object.values(a)
Array.isArray(Object.entries(a))
Array.isArray(Object.keys(a))
Array.isArray(Object.values(a))
'name' in a
a['name'] === 'apple'
Object.keys(a).indexOf('name') !== -1
Object.values(a).indexOf('apple') !== -1
var val,
property;
for (property in a) {
if (a.hasOwnProperty(property)) {
val = a[property];
console.log(property + ': ' + val);
}
}
a = {}
b = dict()
type(a)
type(b)
a
b
a['name'] = 'apple'
a['color'] = 'red'
a
list(a.items())
list(a.keys())
list(a.values())
type(a.items())
type(a.keys())
type(a.values())
'name' in a
('name', 'apple') in a.items()
'name' in a.keys()
'apple' in a.values()
for key, value in a.items():
print(key + ': ' + value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment