-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionparameter.js
More file actions
32 lines (22 loc) · 881 Bytes
/
Copy pathfunctionparameter.js
File metadata and controls
32 lines (22 loc) · 881 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
/** Ceate a simple JavaScipt function named displayInfo that takes to paametes (name and ole) and
logs a message
Use call to invoke the displayInfo function ith specific aguments
Use apply to invoke the displayInfo function ith aguments passed as an aay
Ceate anothe function named geet that logs a geeting ith this context
Use bind to ceate a ne function boundeet ith a specific context and log the geeting. */
function displayInfo(name, role) {
console.log(`Name: ${name}, Role: ${role}`);
}
displayInfo.call(null, "Richa", "Developer");
displayInfo.apply(null, ["Amit", "Designer"]);
function greet() {
console.log(`Hello, ${this.name}!`);
}
let person = { name: "Richa" };
let boundGreet = greet.bind(person);
boundGreet();
/*** output
Name: Richa, Role: Developer
Name: Amit, Role: Designer
Hello, Richa!
*/