-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathof.js
29 lines (25 loc) · 1.22 KB
/
of.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';
// TOPIC /////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Array method: Array.of()
//
// SYNTAX ////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Array.of(element1, element2, ...)
//
// SUMMARY ///////////////////////////////////////////////////////////////////////////////////////////////////
//
// • Array.of() returns a new array instance with the specified elements in the parameters.
// • Array.of() differs from Array() in that with integer arguments Array.of() creates an array with
// a single element whereas Array() creates an empty array with a length of X.
//
// EXAMPLES //////////////////////////////////////////////////////////////////////////////////////////////////
//
// EXAMPLE 1: Array.of vs Array
//
// RESOURCES /////////////////////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EXAMPLE 1: Array.of vs Array
console.log(Array.of(5)); // [ 5 ]
console.log(Array(5)); // [ <5 empty items> ]