So, say I had the following script:
var hey = {
foo: 1,
bar: 2,
baz: 3,
init: function(newFoo){
this.foo = newFoo;
return this;
}
}
hey.check = function(){
alert('yeah, new function');
}
Basically, I can call new hey.init(999)
and get a new hey
variable with hey.foo
set to 999. But when I do that, hey.init(999).check()
is no longer defined. Is there a way to mimic the script, but allow new hey
's to have the extended variables/functions?
EDIT: changed hey.check()
to hey.init(999).check()
sorry about that...