php:
class A{
public function foo(){echo('A')}
}
class B extends A{
public function foo(){echo('B')}
}
$test = new B();
$test->foo(); //echo 'B'
JS:
function A(){
this.foo = function (){alert(('A')};
}
function B() {
this.foo = function (){alert( ('B')};
A.call(this); //foo is override by parent class. must be on beginning of class
}
var test = new B());
test.foo());//alert 'A'
inheritance is called on bad position.
php: class A{ public function foo(){echo('A')} } class B extends A{ public function foo(){echo('B')} } $test = new B(); $test->foo(); //echo 'B'
JS: function A(){ this.foo = function (){alert(('A')}; } function B() { this.foo = function (){alert( ('B')}; A.call(this); //foo is override by parent class. must be on beginning of class } var test = new B()); test.foo());//alert 'A'