remove all mutliple items from array javascript
arr = [2, 2, 2, 1, 3, 3, 3,3, 4, 5];
arr = arr.sort().filter((item,i)=>!(arr[i] == arr[i+1] || arr[i-1]==arr[i]));
// this will remove all item which are repeating more then one
console.log(arr);
// [1, 4, 5]var ar = [1, 2, 3, 4, 5, 6];ar.pop(); // returns 6console.log( ar ); // [1, 2, 3, 4, 5]var arr1 = [1, 2, 3, 4, 5, 6];var arr2 = arr1; // Reference arr1 by another variable arr1 = [];console.log(arr2); // Output [1, 2, 3, 4, 5, 6]
Also in JavaScript:
- discord.js setinterval
- call method in javascript
- insert js in html
- difference between key and code in javascript
- javascript destructing
- javascript submit form when enter key pressed
- how to use labels in javascript
- resellerclub api with react js
- redux get state without store
- insert json into sql
- post antiforgerytoken jquery
- how to know type of dom element in js
- check if value is NaN
- js is undefined or null
- javascript write to text file stack overflow
- nknown key passed via urlObject into url.format: searchParams
- react onclick parameter
- cannot read property 'props' of undefined react redux functional component
- javascript array to comma separated list
- pd.read_json('data.json') args
- random function javascript
- flutter CircularProgressIndicator
- kotlin read input as int
- how to store textbox data while typing for chrome extension