Skip to content

Instantly share code, notes, and snippets.

View farithadnan's full-sized avatar
:bowtie:
Exorcising

Farith farithadnan

:bowtie:
Exorcising
  • MZM Sdn. Bhd.
  • Malaysia
  • 09:33 (UTC +08:00)
View GitHub Profile
@farithadnan
farithadnan / gist:cfc963678c329bd9a1342aef7c4615a3
Created January 26, 2022 08:23 — forked from chad3814/gist:2924672
deleting array items in javascript with forEach() and splice()
// This is from my comment here: http://wolfram.kriesing.de/blog/index.php/2008/javascript-remove-element-from-array/comment-page-2#comment-466561
/*
* How to delete items from an Array in JavaScript, an exhaustive guide
*/
// DON'T use the delete operator, it leaves a hole in the array:
var arr = [4, 5, 6];
delete arr[1]; // arr now: [4, undefined, 6]