Possible Duplicate:
Function vs. Object Literal Notaion - is there a diifference?
I'm playing around in nodejs and I got to a place where I can do the same thing in two different ways.
var x = function(arr) {
this.get = function(index) {
return arr[index];
}
}
var myVar = new x([1,2,3,4]);
or
var y = function(arr) {
return {
get: function(index) {
return arr[index];
}
}
}
var myVar = y([1,2,3,4]);
There's obviously some difference between these two methods, my question is which? Thanks