1// Get keys of a dictionary
2let dict = { a:1 , b:2 , c:3 }
3
4console.log( Object.keys(dict) ) // expected output : ['a', 'b', 'c']
1const person = {
2 name: 'Bob',
3 age: 47
4}
5
6Object.keys(person).forEach((key) => {
7 console.log(person[key]); // 'Bob', 47
8});
1var myObj = {no:'u',my:'sql'}
2var keys = Object.keys(myObj);//returnes the array ['no','my'];
1var obj = {
2 a: "A",
3 b: "B",
4 c: "C"
5}
6
7console.log(obj.a); // return string : A
8
9var name = "a";
10console.log(obj[name]);