Get the App
SLTechnology News&Howtos  ›  Development  › 

How JavaScript defines a new array using array literals

Shulou Source: shulou.com Published: 2022-06-01 03:05:52 10月03日 Update

This article is about how JavaScript uses array literals to define new arrays. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Define using array direct quantities

Syntax format for array literals: contains multiple lists of values in square brackets, separated by commas.

Var array name = [values list]

If the values list can be empty, an empty array is created.

Example:

Var a = []; / / empty array var a = [1, true, "0", [1Magi 0], {XRX 1je YRO}]; / / Array containing specific elements thank you for reading! This is the end of the article on "how JavaScript defines a new array by using array direct quantities". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Array mode content more article good practical between will create element multiple article format see knowledge examples grammar comma medium package square brackets Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn Xiaomi NVidia MySQL