-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestOperator.js
More file actions
50 lines (31 loc) · 876 Bytes
/
Copy pathrestOperator.js
File metadata and controls
50 lines (31 loc) · 876 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
// Its an example of rest operator
// array with
function rest(a,b,c,...other){
// console.log(...other)
return (a+b+c)
}
const ans = rest(1,2,3,4,5,6)
console.log(ans)
// with objects
const students = {
names:"avni" ,
age:"12" ,
gender:"girl",
}
const {names ,...resting} = students
console.log('students' , names )
// EXAMPLE OF SPREAD OPERATOR -----------------------------------
// array with ---------------------------
let name = [1,2,3,5,8,6]
function spread(name){
return name
}
const sum = spread(...name)
console.log("sum" , sum)
// object with ------------we use old obj of studnets -------------------------------
// Interview question how we can update it in spread operator ----------------------------------
var newStudents = {
...students,
age:19 ,
}
console.log('newStudents' , newStudents)