Last active
June 18, 2024 09:03
-
-
Save mailzwj/f4bf2ff975290976d0fcef146f5357cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
各位前端jser,都来说一说自己了解的Javascript冷知识吧,在这里让这些冷知识逐渐发光发热! | |
大家一起来补充啊... | |
JSON.stringify && JSON.parse
很多人都会用JSON.stringify将一个JSON对象序列化为一个JSON格式的字符串,但是我想知道有多少人知道他的第二个,第三个参数?
var obj = {
a: {
b: 'b',
c: 'c'
}
};
console.log(JSON.stringify(obj));
console.log(JSON.stringify(obj, ['a', 'c'], 4));
你知道两个console结果之间的区别吗?
同样的,还有JSON.parse的第二个参数。
细节请参考:JSON.stringify()、JSON.parse()
typeof对于定义了的变量但值为undefined的变量会输出undefined,而未定义的变量和定义后不赋值的变量都会输出undefined。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
举个栗子: