js.l23 code example

Example: js.l23

// const object = {};
// const obj = new object();





=======================================================================================

//	console.log(obj);
//	console.log(obj.name, obj.age);     	// objectName.propertyName.
//	console.log(obj['friends', 'age']);  	// objectName["propertyName"].
// 	console.log(obj[InterestedTo]);			// when using prompt.
//	obj.addelement = 'bangladesh';         // add new property in this object.
//	obj['addElement'] = '@dulon1254';      // add new property in this object.

=====================================================================================





// console.log to print Object and Object property
const obj = {
   id: 16339202294,
   name: 'Dulon',
   age: 2021 - 1996,
   address: '64-East,Mdpur,Dhaka',
   friends: ['sisir', 'razzak', 'rahat']
}
console.log(obj);
console.log(obj.name, obj.age);     //objectName.propertyName
console.log(obj['friends']);  		//objectName["propertyName"]
 
 


// Using prompt in console.log 
const InterestedTo = prompt('Know about her: [id,name,age,address or frienda]:')

// console.log(obj[InterestedTo]);

if (obj[InterestedTo]) {
   console.log(`true property: ${obj[InterestedTo]}`);
} else {
   console.log(`Error Typing: `);
}




// Add Property in THis object
const obj = {
   id: 16339202294,
   name: 'Dulon',
   age: 2021 - 1996,
   address: '64-East,Mdpur,Dhaka',
   friends: ['sisir', 'razzak', 'rahat']
}

console.log(obj);

obj.addelement = 'bangladesh';         // add new property in this object.
obj['addElement'] = '@dulon1254';      // add new property in this object.

console.log(obj);