-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspread operator.js
More file actions
39 lines (27 loc) · 942 Bytes
/
spread operator.js
File metadata and controls
39 lines (27 loc) · 942 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
// spread operator = ... allows an iterbale such as
// an array or string to be expanded into separate
// elements (unpacks the elemnets)
// ------------------------unpack Element
// let numbers = [1,9,3,4,2,6,7]
// let maximum = Math.max(...numbers) //(unpacks the elemnets)
// console.log(maximum);
// let min = Math.min(...numbers)
// console.log(min);
// let min_num = numbers.sort()
// console.log(min_num);
// -------------------------reverse the string
// let a = "Anil"
// let c = a.split("").reverse().join("")
// console.log(c);
// ------------------------using join method in array
// let a = "Anil"
// let b = [...a].join("-")
// console.log(b);
// ---------------------------concat the array
// let fruits = ["apple","orange","grapes"]
// let veg = ["potatoes","tomato","domestick"]
// let concat = [...fruits,...veg,"eggs"]
// console.log(concat);
// let a = [1,2,3]
// let b = Math.max(...a)
// console.log(b);