Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c5b2b7f

Browse files
Merge pull request #5 from mdnmnahmed/main
Add element at the Beginning/End/Index
2 parents 200a96a + 2d165fa commit c5b2b7f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

‎Array/arrayOperations.js‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const strings = ['n', 'u', 'm'];
44
/**
55
* Add element at the End
66
*/
7-
strings.push('a');
8-
strings.push('n');
7+
strings.push('d');
8+
strings.push('e');
99

1010

1111
/**
@@ -14,6 +14,24 @@ strings.push('n');
1414
strings.pop();
1515

1616

17+
/**
18+
* Add element at the Beginning
19+
*/
20+
strings.unshift('D')
21+
strings.unshift('e')
22+
23+
24+
/**
25+
* Remove First element
26+
*/
27+
strings.shift();
28+
29+
30+
/**
31+
* Add element at the Index
32+
*/
33+
strings.splice(4, 0, 'Num',);
34+
1735

1836

1937
console.log(strings);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /