-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrfun.js
More file actions
62 lines (43 loc) · 865 Bytes
/
arrfun.js
File metadata and controls
62 lines (43 loc) · 865 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
52
53
54
//this refers to the current scope
BTS={
name:"Jimin",
track:"like crazy",
welcome:function(){
console.log(this.name);
}
}
// BTS.welcome()
//arrow function
const eg=(num1,num2)=>(num1+num2)//implicit arrow function
//console.log(eg(1,2))
//explicit arrow func
//console.log(min(1,1))
min=(num1,num2)=>{
return num1-num2
}
console.log(min(1,1))
//In normal func hoisting can be done but in arrow func you can not do hoisting
//normal func
function paint(){
sketch="duck"
console.log(this.sketch);
}
paint()
//arrow func
calli=()=>{
sketch="picasso"
console.log(this.sketch)
}
calli()
//this cannot be used in arrow func
//how you will use obj in arrow func
name=()=>({myname:"mehak"})
name()
course={
fee:500,
cost:8000,
website:function(){
console.log(this.fee);
}
}
course.website()