Skip to content

Instantly share code, notes, and snippets.

@binaryreverse
Created April 14, 2016 06:26
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 binaryreverse/03fb9d03f95e806624e4630b0b6e9588 to your computer and use it in GitHub Desktop.
Save binaryreverse/03fb9d03f95e806624e4630b0b6e9588 to your computer and use it in GitHub Desktop.
Check JS Array for value and not empty
if (typeof array[index] !== 'undefined' && array[index] !== null) {
}
//shortened to...
if (array[index] != null) {
// The == and != operator consider null equal to only null or undefined
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment