Repository navigation
Expand file tree
/
Copy pathObjectFunc.html
More file actions
87 lines (70 loc) · 1.87 KB
/
Copy pathObjectFunc.html
File metadata and controls
87 lines (70 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
<script type="text/javascript">
let obj = {
name
}
// function Person(name, age, sex) {
// this.name = name;
// this.age = age;
// this.sex = sex;
// this.say = function () {
// alert(this.name)
// }
// }
// function Person() {}
// Person.prototype.name = "Nicholas";
// Person.prototype.age = 29;
// Person.prototype.job = "Software Engineer";
// Person.prototype.sayName = function () {
// alert(this.name);
// }
function Person(name, age, job) {
this.name = name;
this.age = age;
this.job = job;
this.friends = ["Shelby", "Court"];
}
Person.prototype = {
constructor: Person,
sayName: function () {
alert(this.name);
}
}
function createPerson(name, age, sex) {
let o = new Object();
o.name = name;
o.age = age;
o.sex = sex;
o.sayName = function () {
alert(this.name);
};
return o;
}
let people = new Person('Fan', 20, 'man')
let person = new createPerson('Fan', 20, 'man')
console.log(Person.prototype.isPrototypeOf(people))
console.log(createPerson.prototype.isPrototypeOf(person))
delete person.name
console.log(person.hasOwnProperty("name"))
function queryBook(month) {
if (month <= 1) {
return 1
} else {
return month + queryBook(month - 1)
}
}
const target = { a: 1, b: 2 };
const source = { b: 4, c: 5 };
const returnedTarget = Object.assign(target, source);
console.log(target);
console.log(returnedTarget);
</script>
</html>