如何用浏览器调试出js代码

如何用浏览器调试出js代码

请问下面的程序为什么我输入到谷歌和火狐里面的console里面没有反应,没有像注释一样给我打印出值

function test(o) {

var i = 0; // i is defined throughout function

if (typeof o == "object") {

var j = 0; // j is defined everywhere, not just block

for(var k=0; k < 10; k++) { // k is defined everywhere, not just loop

console.log(k); // print numbers 0 through 9

}

console.log(k); // k is still defined: prints 10

}

console.log(j); // j is defined, but may not be initialized

}


回答:

你这只是一个方法,没有调用它

function test(o) {

var i = 0; // i is defined throughout function

if (typeof o == "object") {

var j = 0; // j is defined everywhere, not just block

for(var k=0; k < 10; k++) { // k is defined everywhere, not just loop

console.log(k); // print numbers 0 through 9

}

console.log(k); // k is still defined: prints 10

}

console.log(j); // j is defined, but may not be initialized

}

test({a: '1'})

这样不就好了么

以上是 如何用浏览器调试出js代码 的全部内容, 来源链接: utcz.com/p/935591.html

回到顶部