-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShortening_Code.js
More file actions
68 lines (41 loc) · 923 Bytes
/
Shortening_Code.js
File metadata and controls
68 lines (41 loc) · 923 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* --> Condition true */
// Longhand
if (booleanVar === true) {};
// Shorthand
if (booleanVar) {};
/* --> Arrow Function */
// Longhand
function greet(name) {
console.log("Hey " + name);
};
// Shorthand
const greet = name => console.log("Hey " + name);
/* --> Template Literals */
const nameL = "John";
const day = "Friday";
// Longhand
const greedL = "Hi " + nameL + ", have a wonderful " + day + "!";
// Shorthand
const greedS = `Hi ${nameL}, have a wonderful ${day}!`;
/* --> Power of any number */
// Longhand
Math.pow(3,6); // 729
// Shorthand
3**6; // 729
/* --> Assignment Operator */
// Longhand
x = x + y;
// Shorthand
x += y;
/* --> Declaring Variables */
// Longhand
let x;
let z = 'a';
// Shorthand
let y, zs = 'A';
/* --> Ternary Operator */
// Longhand
let isAdultL;
if (age > 17) {isAdultL = true;} else {isAdultL = false;};
// Shorthand
let isAdultS = age > 17 ? true : false;