0

What is []?

Array is confusing for me. But what is [] for?

27th Aug 2020, 8:10 AM
K. Zeppelin
K. Zeppelin - avatar
4 Answers
+ 1
It's an empty array. I suppose you're learning Javascript, so: You're normally assigning this to a variable like: "let languages = []" Arrays are lists of items with specific functions, like "push" which adds specific item to the end, so whe can have a block of code: "let languages = [] // Lets the code know that it's an array function addLanguage(language) { languages.push(language) } if you wouldn't write the = [], it would think it's typeof undefined and the code would produce an error
27th Aug 2020, 8:23 AM
Qui-Gon Jinn
Qui-Gon Jinn - avatar
+ 2
Please use the language tag next time.
27th Aug 2020, 9:33 AM
The future is now thanks to science
The future is now thanks to science - avatar
27th Aug 2020, 8:17 AM
Ipang