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 ad5fb04

Browse files
Creating built in methods in objects
1 parent 2613330 commit ad5fb04

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

‎8_Objects_in_detail/objects.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,27 @@ const property = "age";
4040
console.log(person[property]); // 23
4141
```
4242

43+
#### Built-in-Methods
44+
45+
```js
46+
const dog = {
47+
name: "Fluffy",
48+
bark: () => {
49+
console.log("woof,woof");
50+
},
51+
};
52+
53+
dog.bark(); // woof,woof
54+
55+
// this keyword
56+
const car = {
57+
name: "Lambo",
58+
model: 2019,
59+
Details: function () {
60+
console.log(this.name, this.model);
61+
},
62+
};
63+
64+
car.Details(); // Lambo 2019
65+
```
66+

‎8_Objects_in_detail/objects2.js‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const dog = {
2+
name: "Fluffy",
3+
bark: () => {
4+
console.log("woof,woof");
5+
},
6+
};
7+
8+
dog.bark(); // woof,woof
9+
10+
// this keyword
11+
const car = {
12+
name: "Lambo",
13+
model: 2019,
14+
Details: function () {
15+
console.log(this.name, this.model);
16+
},
17+
};
18+
19+
car.Details(); // Lambo 2019

0 commit comments

Comments
(0)

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