forked from taiansu/astro_04_js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday3_1.js
53 lines (44 loc) · 875 Bytes
/
day3_1.js
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
// foo();
// 具名函式
// Function Declarations
function foo() {
console.log('foooooo')
}
console.log(foo)
// console.log(console.log)
var p = console.log;
p('lalalala')
// 匿名函式
// Function Expression
// var bar = function() {
// console.log('brrrrr')
// }
// paradiams
// function won't hoisting
let baz;
baz = function(x) {
console.log(x + 1)
}
let someFunction = function () {
}
console.log(someFunction.name)
function main() {
let a = someFunction()
}
// console.log(main.name)
// main()
/* function as collection's member */
let funs = [ function(i) { console.log(i + 1)}, function(i) { console.log(i * 2)}, function(i) { console.log(i - 3)},
]
for(let i = 0; i < funs.length; i ++) {
(funs[i])(10)
}
let car = {
brand: 'Toyota',
type: 'RAV4',
year: 2020,
move: function(i) {
console.log(`Drive ${i} miles`)
}
}
car.move(100)