For example:
var myObject = {
 name : 'David',
 age: '30,
 salary:'30000'
}
I need answers like: My name is David, I'm 30 years old. I earned monthly 30000.
Note: Without using '.' DOT operator and for and foreach.
For example:
var myObject = {
 name : 'David',
 age: '30,
 salary:'30000'
}
I need answers like: My name is David, I'm 30 years old. I earned monthly 30000.
Note: Without using '.' DOT operator and for and foreach.
 
    
     
    
    This should work:
var myObject = {
    'name' : 'David',
    'age': '30',
    'salary':'30000'
 };
console.log('My name is '+myObject['name']);
Here is the JSFiddle Example: Link
 
    
     
    
    var myObject = { name : 'David', age: '30', salary:'30000' } //object destructure
let {name, age, salary} = myObject;
console.log(my name is ${name})
 
    
    var myObject = {
    'name' : 'David',
    'age': '30',
    'salary':'30000'
 };
console.log(`My name is ${myObject["name"]}, I'm ${myObject["age"]} years old. I earned monthly ${myObject['salary']}.`);
