Categories
JavaScript Answers

How to create a single value array in JavaScript?

Spread the love

To create a single value array in JavaScript, we use the array literal syntax.

For instance, we write

const arr = [21];

to define the arr array with value 21 inside.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *