for example in PHP
class foo{
function foo($name){ //constructor
$this->name=$name;
}
function sayMyName(){
return $this->name;
}
}
class bar extends foo{
function sayMyName(){
return "subclassed ".$this->name;
}
}
And in JS
function foo(name){
this.name=name;
}
foo.prototype.sayMyName=function(){return this.name};
function bar(){}
bar.prototype=new foo();
bar.prototype.sayMyName=function(){return "subclassed "+this.name};
I am new to javascript, so please enlighten me, Aren't they functionally identical, or am I missing something huge?
If they are identical, how is classical different from prototypal?
thanks in advance...