-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path45_arrow_funct.js
More file actions
executable file
·24 lines (23 loc) · 884 Bytes
/
45_arrow_funct.js
File metadata and controls
executable file
·24 lines (23 loc) · 884 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
//arrow function di objek
//arrow funct bisa digunakan sbg Object Method
//arrow funct tdk bs digunakan utk akses argumen objek, funct generator,
//- kata kunci this dan kata kunci super (dibahas di OOP)
//pastikan arrow funct hanya memang digunakan ketika tidak butuh fitur diatas
const person = {
name: "eko",
sayHello: (name) => {
console.info(`hello ${name}`)
}
};
person.sayHello("budi"); //output hello budi di anonimous function
// bandingkan dengan ini sblm menggunakan arrow function d objek
const parson = {
nama: "ekoooo",
sayHallo: function(nama){
console.info(`hellauuu ${nama}`);
}
};
parson.sayHallo("kuntjorooooo"); //output hellauuu kuntjoro
// -alias sama dengan output objek diatas tanpa arrow function
//kata kunci this pada arrow function mengacu pada window
// sedang this pada anonimous function mengacu pada parent nya