Skip to content

Instantly share code, notes, and snippets.

@bjruberg
Created October 1, 2018 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjruberg/b58aff25354a87ec9889c02efa2568b6 to your computer and use it in GitHub Desktop.
Save bjruberg/b58aff25354a87ec9889c02efa2568b6 to your computer and use it in GitHub Desktop.
// native variant needs to protect against null values
const data = null
const result = Array.isArray(data) ? data.map(item => parseInt(item) : []
// not so with lodash
const result = _.map(null, item => parseInt(item))
// no exception, result is []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment