You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 代码示例lettest1="string";console.log(test1.length);// 6console.log("cat".charAt(1));// "a"letlongString1="This is a very long string which needs \to wrap across multiple lines because \otherwise my code is unreadable.";letlongString2="This is a very long string which needs "+"to wrap across multiple lines because "+"otherwise my code is unreadable.";console.log(longString1===longString2);// true
原始值类型
什么是原始值
字面量
;"test".length
原始值类型有哪些
1. boolean
true
等价的值:非0数字
,非空字符串
,Object
false
等价的值:0
,空字符串 ""
,undefined
,null
,NaN
2. string
区分基本字符串和字符串对象
String()
方法生成的字符串都是基本字符串new String()
生成字符串对象实例长字符串
+
运算符拼接多个字符串\
,以指示字符串将在下一行继续,注意反斜杠后面只能紧跟换行符,负责反斜杠将不起作用。3. number
数值范围
NaN
isNaN()
可以用来判断某个变量或者表达式结果是否为非数值4. null
0
, 所以 null 与任何数值运算,可以看作 0 运算5. undefined
void 0
可以用来替代 undefined典型用法:
注意: 严格比较运算符(===)和比较运算符(==)之间的差别。前者会比较操作数的类型和值,后者会将操作数的类型转换成相同的类型之后做值比较
6. symbol
The text was updated successfully, but these errors were encountered: