I was reading through the Mozilla Javascript documentation and I am a bit confused about the use of the word "literal". Specifically, are all arrays in Javascript considered to be "array literals".
An array is a type of value (it can be stored in variables, passed to functions, etc).
An array literal is a type of syntax. Specifically it refers to [ ... ]
(where ...
is a comma-separated list of values).
Executing an array literal creates an array at runtime. However, there are other ways to create arrays:
var x = new Array();
x
contains an array that was not created from a literal.
Similarly, there are all kinds of operations that produce strings, but only "..."
and '...'
are string literals.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With