Quick actions

cmd+k|ctrl+k

Navigation

Languages

DSA-Array

Snippet info

Language

JavaScript

Visibility

public

Author

abhinayy48

Created

2025-07-08T05:07:47.935087Z

Updated

2025-07-08T05:16:10.365562Z

const strings= ['a', 'b', 'c', 'd'];
const numbers = [1,2,3,4,5];
// Variable array is somewhere in memory and the computer knows it.
// When I do array[2], i'm telling the computer, hey go to the array and grab the 3rd item from where the array is stored.


//push
strings.push('e');  //O(1)

//pop
strings.pop();  //O(1)
strings.pop();  //O(1)

//unshift
strings.unshift('x')  //O(n)

//splice
strings.splice(2, 0, 'alien');

console.log(strings)
INFO