I've been taking a look at Douglas Crockford's JSLint.
One of the conventions that it expects is that arrays be created using
literal notation
var arr1 = [];
as opposed to using a constructor
var arr2 = new Array();
I've been a-googling, but the best reason for this that I can find is
"because it's not necessary to use a constructor".
I'm wondering:
1) Is there a way to tell the difference between arr1 and arr2 as
defined above, once they've been defined?
2) Is there anything, beyond stylstic reasons, to prefer one method over
another?
I've no problem against JSLint choosing a specific convention and
applying it. I'm just wondering if there is anything *beyond* convention
to speak in favour of literal over constructor notation.
One of the conventions that it expects is that arrays be created using
literal notation
var arr1 = [];
as opposed to using a constructor
var arr2 = new Array();
I've been a-googling, but the best reason for this that I can find is
"because it's not necessary to use a constructor".
I'm wondering:
1) Is there a way to tell the difference between arr1 and arr2 as
defined above, once they've been defined?
2) Is there anything, beyond stylstic reasons, to prefer one method over
another?
I've no problem against JSLint choosing a specific convention and
applying it. I'm just wondering if there is anything *beyond* convention
to speak in favour of literal over constructor notation.
Comment