Javascript calling public function in a private function in a class
Exactly like the title, here is a demo of Javascript calling public function in a private function in a class.
var hello = function() { this.hey = function(){ console.log("hey"); } var _this = this; // store this(the hello class) to _this var init = function init() { _this.hey(); // If use this here, it will throw error, because this here refers to the window context } init(); } var h = new hello();
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts