-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
51 lines (39 loc) · 974 Bytes
/
functions.js
File metadata and controls
51 lines (39 loc) · 974 Bytes
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
// function statement aka function declaration
a()
function a(){
console.log("a Hello");
}
// a()
// function expression aka
// b()
var b = function(){
console.log("b Hello");
}
// b is treated like any other variable.
// memory not allocated until it is used.
// b()
// Anonymous function are used where functions are used as values.
// For example in base of variable b.
// variable b is assigned a function.\
// Named function expression
var named = function xyz(){
console.log('named function expression.');
}
named()
// Parameters and arguments.
function x(param1, param2){
// Parameters
}
x(1,2);
// 1,2 are arguments.
// First class functions.
// Functions are treated like any other variable.
// They can be passed as arguments to other functions.
// They can be returned from other functions.
// They can be assigned to variables.
var fn = function(){
return function(){
console.log('Hello');
}
}
console.log(fn());