Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

create javascript array with 1 value

let arr = [42]       // Creates an array with only one element:
                     // the number 42.

let arr = Array(42)  // Creates an array with no elements
                     // and arr.length set to 42.
                     //
                     // This is equivalent to:
let arr = []
arr.length = 42
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #create #javascript #array
ADD COMMENT
Topic
Name
2+1 =