You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionController(param1,param2){constname="hello";letage=21;}Controller.prototype.name="hello";Controller.prototype.contributeTo=function(param){varfoo="world-k";};Controller.staticMethod=function(param){varbar="world-cli";};Object.defineProperty(Controller.prototype,"hello",{get: function(){return"world";},set: function(name){console.log("Do anything with "+name);}});Object.defineProperty(Controller.prototype,"lastname",{get: function(){return"kiwi";}});
output
classController{constructor(param1,param2){constname="hello";letage=21;this.name="hello"}contributeTo(param){varfoo="world-k";}staticstaticMethod(param){varbar="world-cli";}gethello(){return"world";}sethello(name){console.log("Do anything with "+name);}getlastname(){return"kiwi";}}
Features π―
Methods on prototype
Static Methods on prototype
Variables and Literals on prototype
Getters, Setters with defineProperty
Block-level Variables
Note : The babel-plugin-es5-function-to-class will only work properly if there is only one function declared in the input file else it will overwrite with the newest declared function. Will resolve this soon π