Skip to content

Commit e3bb861

Browse files
committed
update objects
1 parent 4902d60 commit e3bb861

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

Example/JSObjects/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
<script src="index.js"></script>
8+
</head>
9+
<body>
10+
</body>
11+
</html>

Example/JSObjects/index.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
info = {
2+
'name': 'joy',
3+
'age' : 12,
4+
'city': 'Beijing'
5+
}
6+
7+
console.log(info.city)
8+
console.log(info['age'])
9+
10+
for (let key in info) {
11+
console.log(key +' '+ info[key]);
12+
}
13+
14+
class Person{
15+
16+
intro() {
17+
18+
console.log('welcome to js...')
19+
}
20+
21+
}
22+
23+
person = new Person();
24+
person.intro();
25+
26+
27+
const calculator = {
28+
add: function(a, b) {
29+
return a + b;
30+
},
31+
subtract: function(a, b) {
32+
return a - b;
33+
}
34+
};
35+
36+
console.log(calculator.add(5, 3)); // 8
37+
console.log(calculator.subtract(8, 2)); // 6
38+
39+

0 commit comments

Comments
 (0)