Quick actions

cmd+k|ctrl+k

Navigation

Languages

Arrays : Introduction

Snippet info

Language

JavaScript

Visibility

public

Author

gyanirocks

Created

2025-03-08T06:00:45.695852Z

Updated

2025-03-08T06:02:20.008353Z

const strings = ['a','b','c','d'];

//push , adding elements to the last of the array
strings.push('e');//O(1)
console.log(strings)
// pop , removing elements from the last of the array
strings.pop();//O(1)
console.log(strings)
// unshift , add an element to the first of the array
strings.unshift('x');//O(n)
console.log(strings)
//splice , adding elements to the mddle of the sarray 
strings.splice(2,0,'alien');//O(n)
console.log(strings)
INFO