What is the diference beetwen an array with () or with [ ]? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

What is the diference beetwen an array with () or with [ ]?

20th Sep 2021, 12:01 PM
leandro bandres
leandro bandres - avatar
2 Respostas
+ 5
https://stackoverflow.com/questions/931872/what-s-the-difference-between-array-and-while-declaring-a-javascript-ar When you create an array using var a = []; You're telling the interpreter to create a new runtime array. No extra processing necessary at all. Done. If you use: var a = new Array(); You're telling the interpreter, I want to call the constructor "Array" and generate an object. It then looks up through your execution context to find the constructor to call, and calls it, creating your array.
20th Sep 2021, 12:10 PM
Pariket Thakur
Pariket Thakur - avatar
20th Sep 2021, 2:52 PM
Ipang