Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ce1230e

Browse files
Javascript Objects
1 parent 9481eba commit ce1230e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎FreeCodeCamp/jsObjects.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var myDog = {
2+
"name": "Coder", // Here it will work if you write - name: "Coder", as well
3+
"legs": 4,
4+
"tails": 2,
5+
"friends": ["Debugger", "Designer"],
6+
}
7+
myDog.name = "Pro Coder" // Changing a property value
8+
myDog.bark = "Bow Bow" // Adding a new Property
9+
10+
console.log(myDog.name) // Pro Coder
11+
console.log(myDog.friends[1]) // Designer
12+
console.log(myDog["legs"]) // 4
13+
console.log(myDog["friends"][0]) // Debugger
14+
console.log(myDog[0]) // undefined
15+
console.log(myDog.bark) // Bow Bow
16+
console.log(myDog['bark']) // Bow Bow
17+
// console.log(myDog[bark]) // it will through an error saying bark is not defined
18+
19+
// Delete a property from an object
20+
console.log(myDog)
21+
delete myDog.bark
22+
console.log(myDog)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /