I tried in my chrome debug console:
>function m(){function toString(){return "abc"}}
undefined
>new m().toString()
"[object Object]"
I expect it to print "abc". Why?
I tried in my chrome debug console:
>function m(){function toString(){return "abc"}}
undefined
>new m().toString()
"[object Object]"
I expect it to print "abc". Why?
You are not using your own toString method (which is a private function inside of m), but the one from Object.
For your own method, you need to assign your toString method to m's prototype, like
m.prototype.toString = function () { return 'abc'; };
function m() {}
m.prototype.toString = function () { return 'abc'; };
console.log((new m).toString());
Your code is wrong. You can try this code and check output here http://jsbin.com/luremulano/edit?html,js,console,output
console.log(m('abc'));
function m(a){
return a.toString();
}