Skip to content

Commit b5f909a

Browse files
authored
remove an item in a specific in an array
1 parent 25312ad commit b5f909a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,26 @@ Array(6).join('👽')
9696
# Check how long an operation takes
9797
```javascript
9898
//The performance.now() method returns a DOMHighResTimeStamp, measured in milliseconds.
99-
//performance.now() is relative to page load and more precise in orders of magnitude. Use cases include benchmarking and other cases where a high-resolution time is required such as media (gaming, audio, video, etc.)
99+
//performance.now() is relative to page load and more precise in orders of magnitude.
100+
//Use cases include benchmarking and other cases where a high-resolution time is required
101+
//such as media (gaming, audio, video, //etc.)
100102

101103
var startTime = performance.now();
102104
doSomething();
103105
const endTime = performance.now();
104106
console.log("this doSomething took " + (endTime - startTime) + " milliseconds.");
105107
```
108+
109+
# Two ways to remove an item in a specific in an array
110+
111+
```javascript
112+
//Mutating way
113+
const muatatedArray = ['a','b','c','d','e'];
114+
muatatedArray.splice(2,1)
115+
console.log(muatatedArray) //['a','b','d','e']
116+
117+
//Non-mutating way
118+
const nonMuatatedArray = ['a','b','c','d','e'];
119+
const newArray = nonMuatatedArray.filter((item'index) => !( index === 2 ));
120+
console.log(newArray) //['a','b','d','e']
121+
```

0 commit comments

Comments
 (0)