Menu
Hi, I'm Pritesh Gupta.
I'm a software engineer based in the San Francisco Bay Area.
←

Navigation

  • Home
  • About Me
  • Contact Me
  • Templates
  • Plugins

Social

  • LinkedIn
  • Twitter
  • GitHub

Copy JavaScript Array with All Items Except One

October 13, 2014
var newArr = (newArr = oldArr.slice(), newArr.splice(newArr.indexOf(item), 1), newArr);

By combining JavaScript's comma operator, Array slice and Array splice, we can conditionally duplicate JavaScript arrays.

Continue reading →

Posts navigation

← Older posts
Newer posts →

© Pritesh Gupta | Archives | Subscribe