The classic way to create constructor function is like:
var Obj = function(param){
this.param = param;
this.method = function(){ console.log(this.param); }
}
But why i can't do something like this:
Obj.anotherMethod = function(){ //some code }
(I know about Obj.prototype.anotherMethod).
In practical usage i can't understand why use String.prototype.func instead of String.func to define new method. Is it just because String is constructor function and it's impossible to add method to it?
newoperator and you will need methods on the new object, not on the function itself).