espace Posted November 12, 2016 Share Posted November 12, 2016 Hi, I'm boring to do this always like this with a lot of flag. is it an another way more simple? Is it possible to do the same with another prototype or method please ? Obj.prototype.set_param=function){ if (this.set_param_flag){ this.set_param_flag=false this.param=false } } Obj.prototype.update=function(){ if (this.flag){ this.set_param() } Link to comment Share on other sites More sharing options...
squilibob Posted November 12, 2016 Share Posted November 12, 2016 Not sure if this is what you are asking but you can reduce the code like this Obj.prototype.set_param=function){ this.param=this.set_param_flag ? this.set_param_flag=false : this.param } Obj.prototype.update=function(){ this.flag && this.set_param(); } Link to comment Share on other sites More sharing options...
espace Posted November 12, 2016 Author Share Posted November 12, 2016 Hey super Could you explain this snippet this.set_param_flag=false : this.param Link to comment Share on other sites More sharing options...
espace Posted November 12, 2016 Author Share Posted November 12, 2016 Thanks for your snippet I have discovered a new feature http://www.w3schools.com/js/js_comparisons.asp Link to comment Share on other sites More sharing options...
Recommended Posts