var DOM_N$ = function(selector){
this.selector = selector;
return "jello world";
}
DOM_N$.prototype = {
getSelector: function(){
return this.selector;
}
}
function N$(selector){
return (new DOM_N$(selector));
}
N$('element').selector; //wont return selector because of return
N$('element'); //returns element
当没有调用其他方法时,我试图从对象返回值,但我的返回中断了我的对象方法。
最佳答案
对于 DOM_N$ 作为构造函数,它应该不返回任何内容
var DOM_N$ = function(selector){
this.selector = selector;
}
关于javascript - JS 方法调用并返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32082363/