Skip to content

Instantly share code, notes, and snippets.

@richardj
Last active June 22, 2016 12:04
Show Gist options
  • Save richardj/e8df8dd1d03d1619e39ecf4d4c87a74c to your computer and use it in GitHub Desktop.
Save richardj/e8df8dd1d03d1619e39ecf4d4c87a74c to your computer and use it in GitHub Desktop.
Best way to check if array exists and if not create on to unshift into
if (!someObject.someArray) {
someObject.someArray = [];
}
someObject.someArray.unshift(item);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment