模式匹配
/^HTML/ -->匹配以HTML开头的字符串 /[1-9][0-9]*/ /\bjavascript\b/i
字符串具有可以接受RegExp的方法
var text = ‘testing:1,2,3‘ var pattern = /\d+/g pattern.test(text) text.search(pattern) text.match(pattern) text.replace(pattern,‘#‘) text.split(/\D+/) -->用非数字截取字符串 text.split(/\d+/) -->用数字截取字符串
布尔值
false的布尔值有
undefined null 0 -0 NaN ""
true的布尔值有
所有其他值
注意:Infinity -Infinity是true
null和undefined
null和undefined都是自有类型的唯一成员 typeof(null) -->‘object‘ typeof(undefined) -->‘undefined‘
判断运算符"=="认为两者是相等的,要使用严格运算符"==="来区分它们。
两者都不包含任何属性和方法,也就是不能用‘[]‘,‘.‘来存取这两个值的成员或方法。
全局对象
var global = this 在客户端JavaScript中window可以替代this
包装对象
var s = "test",n = 1,b = true var S = new String(s) var N = new Number(n) var B = new Number(b) typeof(s) -->"string" typeof(n) -->"number" typeof(b) -->"boolean" typeof(S) -->"object"包装对象的类型都是object "=="等于运算符将原始值和其包装对象视为相等, "==="全等运算符将他们视为不等
原文:http://www.cnblogs.com/zhoulixue/p/6430163.html