var p = Array(0); // []
[] var p = [] // []
Both work the same way to create an empty array.
var p = Array(3); //[undefined, undefined, undefined]
Which you can also do using :
var p = [undefined, undefined, undefined];
Again both work the same way internally but have different use cases :
For ex. If you want to create an array with n elements :
var array = new Array(n) // [undefined * n]
If you want to initialise values of arrays while creation :
var arry = [1,2,3,4];
One thing to note here is you can create an initialized array with new Array()
as well :
var p = new Array(1,2,3,4); // [1,2,3,4]
But when you try to create an array with one initialised value it takes that one parameter and create an array of that size :
var p = new Array(4) // [undefined*4]