Im having trouble with the different ways for declaring js-objects, especially after reading the knockout.js documentation. They seem to mix all possible ways. What is the big difference between these four ways of declaring an object?
var object = new Object();
name.field = bla;
name.method = function() { bla };
var object = {
field : "bla",
method : function() { bla };
}
--> I guess these are equivalent, just different notations. But in the second case, how would you pass parameters? Or isnt it possible at all?
And in the two bwlo: Whats the difference between storing it in a variable and not storing it in a variable (other than the way the object would be passed to a function)?
function object() {
this.field = "bla";
this.method = function() { bla };
}
otherfunction(new Object());
var myobject = function name() {
this.field = "bla";
this.method = function() { bla };
}
otherfunction(new myobject());
otherfunction(myobjet);
EDIT: Sorry for asking again, didn't see the other one in the suggested topics.