Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

dot notation vs bracket notation

/* The dot notation and bracket notation both are used to access the object 
properties in JavaScript. */

/* The main difference between dot notation and bracket notation is that the 
bracket notation allows us to access object properties using variable. */

// Object
let obj = {
	firstName: 'Derrick'
  	lastName: 'Rose'
}

// Dot notation
console.log(obj.firstName)
// Output: Derrick

// Bracket notation
console.log(obj['lastName'])
// Output: Rose
Comment

dot notation vs bracket notation javascript

let obj = {
  cat: 'meow',
  dog: 'woof'
};
let sound = obj.cat;
console.log(sound);
// meow
Comment

PREVIOUS NEXT
Code Example
Javascript :: convert componentDidUpdate into useEffect 
Javascript :: wrap three three set div in a single div 
Javascript :: veu js vs angular vs react features 
Javascript :: scale sprite matter.js 
Javascript :: xpath last node 
Javascript :: como saber si un afecha es mayor o menor js 
Javascript :: https://ssl.clickbank.net/order/orderform.html?time=1637595355&vvvv=62766b313233&item=6&cbfid=35141&cbf=YQYI4X5NDF&vvar=cbfid%3D35141&corid=1ee8f46f-018e-4c7d-ba0c-733317d97f43 
Javascript :: execute powershell command from javascript 
Javascript :: react birthday 
Javascript :: JavaScript endsWith() example with length parameter 
Javascript :: google sheets simulate edit event 
Javascript :: nodejs app.on connection 
Javascript :: animating using jquery 
Javascript :: Access nested objects and arrays using string path 
Javascript :: delete all elements with class javascript 
Javascript :: javascript swap 
Javascript :: Import UI library modularized in nuxtjs 
Javascript :: flyweight 
Javascript :: Find specific string by using includes in javascript 
Javascript :: js what does the vertical line symbol do 
Javascript :: Check for particular values in the response body 
Javascript :: FTP Get a directory listing of the current 
Javascript :: jquery code to javascript converter 
Javascript :: ios ad mobs 
Javascript :: node.js sign in to website and get contents of new page 
Javascript :: convert datetime to milliseconds in javascript 
Javascript :: function for making something invisible in gdscript 
Javascript :: on scroll image blur jquery 
Javascript :: javascript one line if without else 
Javascript :: botstrap 5 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =