object name js code example
Example 1: adding function to objects js
var myObj = {
myFunc: function(param){
//do stuff
}
}
Example 2: javascript object string property
// Also useful for dynamic strings, e.g. `thing-${variable}`
myObject['thing'] = true;
Example 3: get object name javascript
var a = {
name:'a',
'light': 'good',
'dark' : {
name: 'dark',
'black': 'bad',
'gray' : 'not so bad'
}
}
// This way you can do
console.log(a.name,a.dark.name);