- If no, could you please provide an example of a non-literal array.
- If yes, could you please provide an example of a variable that has a literal and non-literal variety (assuming such a thing exists) and explain how it differs to an array.
literal means an array value written as code, like this :
[4, 5, 6]
let array1 = [4,5,6]; console.log(array1);
An array, is an object with the type Array.
You can create an array by writing an array litteral, or by other ways, for instance (as another answer mentioned) by using the Array constructor, or with for instance the
split function :
"4 5 6".split(' ');
let myString = '4 5 6'; let array2 = myString.split(' ' ); console.log(array2);
the result of the split function is an array as well, but it is not written literally in the code.