Skip to content

Commit e0f2032

Browse files
committed
added slice or splice
1 parent 728eaa8 commit e0f2032

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,34 @@ const second = [55, 44, 24, 78, 61];
237237
console.log(first1.concat(second));
238238
```
239239

240+
### Array slice or splice.
241+
242+
```javascript
243+
const number1 = [33, 534, 24, 76, 89, 90, 06, 46];
244+
245+
// slice
246+
console.log(number1.slice(3, 7)); //[76, 89, 90, 6]
247+
248+
// splice
249+
console.log(number1.splice(3, 5)); //[ 76, 89, 90, 6, 46 ]
250+
251+
console.log(number1.splice(3, 4));
252+
console.log(number1); // [ 76, 89, 90, 6 ]
253+
//after splice,the array list is now - [ 33, 534, 24, 46 ]
254+
255+
// added number of list
256+
console.log(number1.splice(3, 0, 222, 336, 553, 2178)); //[]
257+
console.log(number1); // [ 33, 534, 24, 222,336, 553, 2178, 76,89, 90, 6, 46]
258+
```
259+
260+
```javascript
261+
262+
```
263+
264+
```javascript
265+
266+
```
267+
240268
```javascript
241269

242270
```

array-slice.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const number1 = [33,534,24,76,89,90,06,46];
22
// console.log(number1.slice(3,5));
33
// console.log(number1.splice(3,5));
4-
console.log(number1.splice(3,2,222,336,553,2178));
4+
// console.log(number1.splice(3,4));
5+
// console.log(number1);
6+
console.log(number1.splice(3,0,222,336,553,2178));
57
console.log(number1);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy