请参考 - https://jsfiddle.net/53ranmn5/1
Array.prototype.method1 = function() {
console.log("method1 called");
}
[1,2,3,4].method1();
Run Code Online (Sandbox Code Playgroud)
我收到以下错误,
类型错误:无法读取性能
'method1'的undefined
为什么这样?我怎样才能解决这个问题?
请参考 - https://jsfiddle.net/jy5p509c/
var a = "who all are coming to the party and merry around in somewhere";
res = ""; resarr = [];
for(i=0 ;i<a.length; i++) {
if(a[i] == " ") {
res+= resarr.reverse().join("")+" ";
resarr = [];
}
else {
resarr.push(a[i]);
}
}
console.log(res);
Run Code Online (Sandbox Code Playgroud)
最后一个字不会反转,也不会在最终结果中输出.不确定缺少什么.
递归没有发生?任何人都可以指出为什么?
function a() {
console.log("xx");
console.log(this);
a();
}
var a2 = new a();
Run Code Online (Sandbox Code Playgroud)