javascript面试题
1 function Foo() { 2 getName = function () { alert (1); }; 3 return this; 4 } 5 Foo.getName = function () { alert (2);}; 6 Foo.prototype.getName = function () { alert (3);}; 7 var getName = function () { alert (4);}; 8 function getName() { alert (5);} 9 10 //答案: 11 Foo.getName();//2 12 getName();//4 13 Foo().getName();//1 14 getName();//1 15 new Foo.getName();//2 16 new Foo().getName();//3 17 new new Foo().getName();//3
原文见https://www.jb51.net/article/79437.htm