let objectName = {key1: value1, key2: value2}<objectName>.<keyName> //quicker than bracket notation<objectName>[<keyName>] //can be used with keyName that contains spacesMethods: function objects that’s assigned to an object, invoked with .() notation. Syntax: objectName.functionName();
let profileContainer = document.getElementbyID('elementID') //create the elementlet kittenArticle = document.createElement('article')) //create an <article> on JSkittenArticle.textContent = "some text about the kitten"profileContainer.appendChild(kittenArticle); //this appends the new article element to the parent
document.querySelector('article;nth-child(2) h3') //targeted h3 that's second child as an article element any CSS selector can be included in the quotation marksthis: keyword refers to the current object the code is being written inside.const dog = { name: ‘Spot’, age: 2, color: ‘white with black spots’, humanAge: function (){ console.log(
${this.name} is ${this.age*7} in human years); }
this refers to the object dog. The advantage of using this is that the dynamic argument wouldn’t have to be hard-coded, and the code can be reused when the object name is updated. This can especially useful in the case of generic data name such as “Q1_20xx” or “Q2_20xx”, etc.