Last active
June 22, 2016 12:04
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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