How to make an array out of any value (string or other) in Javascript
You can use is array-make open source component to any Javascript value (including string) with an array.
Examples:
makeArray(1) // => [1]
makeArray([1]) // => [1]
makeArray(null) // => []
It also has 3 tests passed:
makeArray() should wrap an empty string with an array
makeArray() should return an empty array as nil value was passed
makeArray() should return the same array reference if an existing array was passed
Written by Codi
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#