R
Ray
Hello,
While reading another guy's I found myself a bit confused by his way of
declaring his class--I usually declare a class like this:
function Foo() {
this.blah = true;
this.bleh = false;
}
Foo.prototype.blabla = function() {
};
and so on. However in his code he does a lot of this:
var Foo = {
blah : true,
bleh : false,
blabla : function() {
}
};
My question is, how are they different? I mean I guess he's declaring
his class JSON style. But can he even do a new() on his class? Seems
like then he's limited to using his methods and variables statically,
e.g.: Foo.blah, Foo.bleh, Foo.blabla() and so on.
Is there any particular reason why one would do that?
Thank you!
Ray
While reading another guy's I found myself a bit confused by his way of
declaring his class--I usually declare a class like this:
function Foo() {
this.blah = true;
this.bleh = false;
}
Foo.prototype.blabla = function() {
};
and so on. However in his code he does a lot of this:
var Foo = {
blah : true,
bleh : false,
blabla : function() {
}
};
My question is, how are they different? I mean I guess he's declaring
his class JSON style. But can he even do a new() on his class? Seems
like then he's limited to using his methods and variables statically,
e.g.: Foo.blah, Foo.bleh, Foo.blabla() and so on.
Is there any particular reason why one would do that?
Thank you!
Ray