Syntax
JavaScript Create an Array Syntax
In JavaScript, create an array: creates an ordered list of values — const nums = [1, 2, 3];
Quick Answer
- Syntax
const nums = [1, 2, 3];
JavaScriptSyntax
Create an Array
Code example
const nums = [1, 2, 3];
Creates an ordered list of values.
How to create an array in JavaScript
- Open your JavaScript file or editor.
- Copy the example, then replace its sample names and values for your code.
JavaScript Create an Array Syntax
Use const nums = [1, 2, 3];.
Related Syntax References
Frequently asked questions
What is the JavaScript syntax for create an array?
Use this pattern: const nums = [1, 2, 3];
Can I copy this JavaScript code example?
Yes. Use Copy code and adapt the example to your program.
Is this JavaScript syntax different on Mac or Windows?
No. The language syntax is the same across operating systems.
Official source · How we verify