Which if the following two methods is the best / most practical to use?
var arr = (new function (){
this.Foo = "Foo";
this.Bar = "Bar";
});
OR
var arr = new Array (
Foo = "Foo",
Bar = "Bar"
)
I understand that both of the above can have properties added to them, Please note there is currently no application of the above code so no context around the question, but which is more preferred? Thanks
FooandBarand then immediately instantiates it. The second code fragment creates an array with elements"Foo"and"Bar"(and in the process creates two new global variablesFooandBar). Whether you want an object with two properties, or an array with two elements, is up to you.