Basic Javascript (83/111) | Accessing Object Properties with Bracket Notation | freeCodeCamp

Published: 10 November 2020
on channel: Stral Tech
208
1

Basic Javascript (83/111) | Accessing Object Properties with Bracket Notation | freeCodeCamp

Full playlist 👉    • Basic JavaScript (1/111) | Comment Yo...  

"The second way to access the properties of an object is bracket notation ([]). If the property of the object you are trying to access has a space in its name, you will need to use bracket notation.

However, you can still use bracket notation on object properties without spaces.

Here is a sample of using bracket notation to read an object's property:

var myObj = {
""Space Name"": ""Kirk"",
""More Space"": ""Spock"",
""NoSpace"": ""USS Enterprise""
};
myObj[""Space Name""]; // Kirk
myObj['More Space']; // Spock
myObj[""NoSpace""]; // USS Enterprise
Note that property names with spaces in them must be in quotes (single or double).

Read the values of the properties ""an entree"" and ""the drink"" of testObj using bracket notation and assign them to entreeValue and drinkValue respectively."


Watch video Basic Javascript (83/111) | Accessing Object Properties with Bracket Notation | freeCodeCamp online, duration hours minute second in high quality that is uploaded to the channel Stral Tech 10 November 2020. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 208 times and liked it 1 visitors.