-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsScript.js
More file actions
39 lines (26 loc) · 928 Bytes
/
JsScript.js
File metadata and controls
39 lines (26 loc) · 928 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
const btn=document.querySelector("#btn");
const msg=document.querySelector("#divMsg");
var arr=[22,34,35,76,78];
var arr2;
var arr3;
btn.addEventListener("click",()=>{
//unshift();
//arr.unshift(40); // adds item at first of the array
// Shift()
//arr.shift(); // removes item from first index onwards
// arr.shift(); // will remove next item
// arr.shift();
// arr.shift();
// arr.shift();
// arr.shift();
// arr.pop(); // removes item from the end of array
// arr.pop();
// arr.push(1000); // adds item at the end of array
// arr.push(22);
//arr.reverse(); // reverse the array value.
arr2=arr; // ref copy
arr3=[...arr]; // value copy
arr.reverse(); // value of arr3 will not reverse.
//arr3.reverse();
msg.innerHTML=`value of arr2 : ${arr} <br/> value of arr2 : ${arr2} <br/> value of arr3 : ${arr3}`;
});