对象访问
book.topic
等价于
book['topic']
var index = "topic" book[index] 等价于 book.topic
Math函数
Math.pow(2,3) Math.round(1.6) Math.ceil(0.6) Math.floor(0.6) Math.random()
NaN,Infinity,-Infinity
0/0 = NaN n/0 = Infinity -n/0 = -Infinity 判断是否是NaN x != x -->为true isNaN(x) -->为true 判断是否是NaN,Infinity,-Infinity isFinity(x) -->为true
字符串方法
var str = 'Hello world' s.charAt(0) -->'H'
s.substring(1,4) -->'ell' s.substring(4) -->'o world' s.substring(-4) -->'Hello world' s.slice(1,4) -->'ell' s.slice(4) -->'o world' s.slice(-4) -->'orld' sustring和slice方法大体相同但是在传入负数时,slice返回后几位字符,substring返回字符串。
s.indexOf('l') -->2 s.lastIndexOf('l') -->9 s.indexOf('l',3) -->3 'l'在3及3之后首次出现的位置
s.split(',') s.replace('l','L') s.toUpperCase() s.toLowerCase()