Untitled
unknown
plain_text
a year ago
810 B
8
Indexable
// array methods
// let temp = [1, 2, 3, 4, 5];
// function customPop() {
// let temp1 = [];
// for (let i = 0; i < temp.length - 1; i++) {
// temp1.push(temp[i])
// }
// return temp1;
// }
// console.log(customPop())
// shift method - remove the first element of array
// temp.shift();
// console.log(temp)
// pop method - remove the element from the last of array
// let temp = [1, 2, 3, 4, 5];
// temp.pop();
// console.log(temp);
// unshift - add the element in the starting of array
// let temp = [1,2,3];
// temp.shift(22);
// [22,1,2,3]
// let temp = [1, 2, 3, 4, 5];
// let temp1 = [];
// for (let i = 0; i < temp.length; i++) {
// if (i == 0) {
// temp1.push(11,temp[i]);
// }
// else {
// temp1.push(temp[i])
// }
// }
// console.log(temp1)Editor is loading...
Leave a Comment