-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapps.js
65 lines (52 loc) · 1.35 KB
/
apps.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
54
55
56
57
58
59
60
61
62
63
64
65
//Anon Function
// const doctorize = function (firstName) {
// return `Dr. {firstName}`;
// };
//Function expression :: Variable Stored function.
// const doctorize = function (firstName) {
// doesntExist();
// return `Dr. ${firstName}`;
// };
//Hoisting
// console.log(doctorize3("Samuelsons"));
// const doctorize = function (firstName) {
// doesntExist();
// return `Dr. ${firstName}`;
// };
// const doctorize = function (firstName) {
// doesntExist();
// return `Dr. ${firstName}`;
// };
// function doctorize3(firstName) {
// return `Dr. ${firstName}`;
// }
//Function declaration
// function inchtoCM(inches) {
// return (cm = inches * 2.54);
// }
//anonymous function :: function without a function name.
// const inchtoCM = function (inches) {
// return (cm = inches * 2.54);
// };
// Arrow function
// Remove function & return keywords and also remove curly braces.
// const inchtoCM = (inches) => (cm = inches * 2.54);
// function add(a, b = 3) {
// const total = a + b;
// return total;
// }
// const add = (a, b = 3) => a + b;
// returning an object
function makeAbaby(first, last) {
const baby = {
name: `${first} ${last}`,
age: 0,
};
return baby;
}
// IIFE
// Immediately Invoked Function Express
(function () {
console.log("Running the anon function.");
return `Your are cool and your age is ${age}`;
})(25);