Javascript functions can be declared on a objects prototype like this:
<object name>.prototype.<variable name>=function(){
//
//
}
How it this different than following declaration?
<object name>.<variable name>=function(){
//
//
}
How are prototype functions different than normal functions in javascript ?
functions declared on a base object’s prototype are inherited by all instances of that object type.
For example..
Now, every string will have the function foo() available.
'test'.foo(); // returns 'bar'Read more about prototype-based inheritance here