简单代码
var person = {
name: 'Andrew'
};
person.age = 25;
debugger;
person.name = 'Mike';
console.log(person);
我正在调试模式下运行它
debug> n
break in playground/debugging.js:1
> 1 (function (exports, require, module, __filename, __dirname) { var person = {
2 name: 'Andrew'
3 };
debug> n
break in playground/debugging.js:5
3 };
4
> 5 person.age = 25;
6
7 debugger;
无论如何我都无法操纵人对象
debug> person
repl:1
person
^
ReferenceError: person is not defined
at repl:1:1
at ContextifyScript.Script.runInContext (vm.js:59:29)
at Object.runInContext (vm.js:120:6)
为什么?
答案 0 :(得分:1)
person
在调试模式下不是有效命令。在调试模式下,请参见list of commands。
如果您想在逐步操作时观看人物对象,请使用watch
debug> watch('person')
这将逐步印出人的价值。