what is the difference (if there is any) between
x = Array()
and
x = new Array()
in CoffeeScript (or JavaScript for that purpose)? Which one should I use?
what is the difference (if there is any) between
and
in CoffeeScript (or JavaScript for that purpose)? Which one should I use? |
|||||
|
The spec says:
|
|||
|
I believe that both are equivalent. However, in JavaScript at least, you should always use the literal syntax:
But based on some tests in the browsers I have, |
|||||||||||||||||||||
|
You should use the literal
The reason you can use
That is, if you call |
|||
|