work
This commit is contained in:
parent
d4c714cbe1
commit
03cbee39ae
89 changed files with 1579 additions and 1826 deletions
16
archive/proto/user.js
Normal file
16
archive/proto/user.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
```js run
|
||||
function User(name, birthday) {
|
||||
let age = calcAge();
|
||||
|
||||
function calcAge() {
|
||||
new Date().getFullYear() - birthday.getFullYear();
|
||||
}
|
||||
|
||||
this.sayHi = function() {
|
||||
alert(name + ', age:' + age);
|
||||
};
|
||||
}
|
||||
|
||||
let user = new User("John", new Date(2000,0,1));
|
||||
user.sayHi(); // John
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue