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 :: dynamodb count items node 
Javascript :: what is react reveal 
Javascript :: React-native-background-fetch 
Javascript :: script refresh js 
Javascript :: JavaScript querySelector - By class 
Javascript :: This function is used to store items in local storage 
Javascript :: indexof javascript 
Javascript :: polymorphism javascript 
Javascript :: javascript this Inside Object Method 
Javascript :: js to find min value in an array 
Javascript :: javascript number and math 
Javascript :: how to add icon in javascript 
Javascript :: NodeJS Content-Type 
Javascript :: nested function 
Javascript :: js select all 
Javascript :: nodejs redis 
Javascript :: blockchain javascript 
Javascript :: angular set time 
Javascript :: check if jwt token is valid 
Javascript :: how to push array object name javascript 
Javascript :: todo list javascript 
Javascript :: js add event listener 
Javascript :: js create nested object from array 
Javascript :: add select option jquery 
Javascript :: javascript map method 
Javascript :: The Lodash Array Remove Method 
Javascript :: datatable hide no data available in table 
Javascript :: delete item from array of objects javascript 
Javascript :: charat javascript 
Javascript :: chrome-aws-lambda 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =