1

Usage of the var myArray = Array(10).fill(0); and var myArray = new Array(10).fill(0); seemingly return the same result.

Are there any differences between these two expressions? When should you use the new keyword and when should you not?

5
  • 2
    It's in the spec that the Array constructor must work that way. Not all constructors do however. Commented Nov 13, 2018 at 15:20
  • 1
    stackoverflow.com/questions/26496609/… Commented Nov 13, 2018 at 15:20
  • This link may help you: stackoverflow.com/questions/8205691/array-vs-new-array Commented Nov 13, 2018 at 15:21
  • 1
    Thank you @Bhojendra Rauniyar. Commented Nov 13, 2018 at 15:24
  • 1
    @T.J.Crowder I really love your comments whenever I see you delete the post. Commented Nov 13, 2018 at 15:31

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.