Home >Web Front-end >JS Tutorial >What do Square Brackets [] Mean in JavaScript?

What do Square Brackets [] Mean in JavaScript?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-22 08:31:16449browse

What do Square Brackets [] Mean in JavaScript?

What does this symbol mean in JavaScript?

Square brackets: [ ]

Meaning: Array notation

Usage:

const arr = [1, 2, 3]; // Create an array

console.log(arr[1]); // Access the second element (0-indexed)

Other relevant links:

  • [The MDN documentation on arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
  • [Another Stack Overflow question about square brackets in JavaScript](https://stackoverflow.com/questions/9834703/array-creation-in-javascript)

The above is the detailed content of What do Square Brackets [] Mean in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn