question part 1: i've made object constructor properties in it, wondering if define property of object within 1 of it's methods. example:
var player = function(p1) { this.property1 = p1; this.property2 = 0; }
then, can define this.property3
in method, like:
player.prototype.drawmethod = funtion() { this.property3 = 1; }
and have accessible, like:
var obj = new player(true); if (obj.property3 ===1 && obj.property1 === 1) { //code } else { obj.property3 = obj.property2; }
question part 2: also, properties accepted functions, , call them using following way:
this.func = function() { //code } ... obj.func();
i wondering if define property of object within 1 of it's methods
yes can.
but notice considered bad style, because it's not visible @ 1 single point (the constructor) properties instances have. engines known not optimise case - reserve necessary space shape of object constructor creates, , changing after instantiation requires work.
will properties accepted functions, , call them [like methods]?
yes.