Please indicate the source of the reprint: http://blog.csdn.net/zhaoyanjun6/article/details/126524473
This article comes from [Zhao Yanjun's blog]
Article directory
debugger
The debugger keyword is used to stop JavaScript execution and call a debug function.
This keyword has the same effect as setting a breakpoint in a debugging tool.
The debugger statement will not work if no debugger is available.
With the debugger enabled, the code stops executing before the third line.
Example:
var x = 15 * 5;
debugger;
document.getElementbyId("demo").innerHTML = x;
Turn on debug mode
add breakpoint
Open the control panel, clickSources
JSON
script>
//定义对象
user = {
"name": "zhaoyanjun", "age": 20, "man": false}
function aa() {
console.log("json " + user.name + " " + user.age)
//把对象转换为 json 字符串
const jsonString = JSON.stringify(user)
console.log("json " + jsonString)
//把json 字符串转换成对象
const user2 = JSON.parse(jsonString)
console.log("json " + user2.name)
}
</script>
The effect is as follows:
- traverse all keys
//遍历所有Json key
for (const user2Key in user) {
console.log("json key " + user2Key)
}
- create json string
const json = JSON.stringify({
color: 1, size: 100})
console.log(json)