es6 class funciton call other class function code example

Example 1: js class static function

class myClass{
 
constructor(){
this.myLocaleVariable=1;//this.varname in the constructer function makes a locale var
}
localfunction(){
return "im local unique to this variable";
}
static publicfunction(){
return "i can be called without an obj"
}
  
}
myClass.myPublicVariable = 0;



myClass.localfunction();//error
myClass.publicfunction();//"i can be called without an obj"
myClass.myLocaleVariable;//error
myClass.myPublicVariable;//0
var obj = new myClass;
obj.localfunction();//"im local unique to this variable"
obj.publicfunction();//error
obj.myLocaleVariable;//1
obj.myPublicVariable;//error

Example 2: python class call base constructor

class Base(object):
   def __init__(self, value):
       self.value = value

class Child(Base):
   def __init__(self, something_else):
       Base.__init__(value=20)
       self.something_else = something_else

Example 3: javascript function call with variable

function abc() {
  alert('test');
}

var funcName = 'abc';

window[funcName]();