Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For unique, I prefer to let javascript do the work:

  // Grab unique
  [...new Set([1,1,2,3,4])]


Although it wouldn't work if you were using objects and wanted to do a deep comparison e.g.

    [...new Set([{x: 1}, {x: 1}])]


Yeah, I recently did a project in Javascript (as a longtime C++ programmer) and was bitten by this exact problem.

Javascript is great but sometimes I miss the predicability of the STL.


... an important observation, for sure.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: