一 简介
以下“常用方法”指“常用的原型方法”。
二 Object
概念:
常用方法:
Object.create
Object.prototype.toString
Object.prototype.hasOwnProperty
判断一个属性是自身属性,还是原型链上的属性。
三 String、Number、Boolean
1 Boolean
概念:
其他类型向布尔型转换:
2 String
概念:
常用方法:
String.prototype.indexOf
String.prototype.replace
String.prototype.split
3 Number
概念:
常用方法:
- Number.prototype.toFixed
四 Array
概念:
常用方法:
Array.prototype.splice
Array.prototype.forEach
五 Function
- 概念:
自定义对象构造器:
- 常用方法:
Function.prototype.apply
Function.prototype.bind
通过把返回值赋给变量 circlemove,然后用 setTimeout 函数让点推迟一定时间移动。
子类构造器:
函数调用的三种方式:
- ()
- apply,call 。指定函数调用者和参数。
函数参数特点:
形参个数不一定等于实参个数。
值传递。
通过参数类型检查实现函数重载。arguments
arguments 对象是在函数执行时函数内部生成的。值传递:
六 RegExp、Date、Error
1 RegExp
概念:
常用方法:
- RegExp.protorype.test
2 Date
- 概念:
3 Error
N/A
七 Math、JSON
1 Math
概念:
常用方法:
Math.floor
Math.random
2 JSON
概念:
常用方法:
JSON.stringify
JSON.parse
八 全局对象
概念:
几个重要的属性和方法:
NaN
parseInt
eval
示例代码,将字符串转成 JSON 对象。
通常不建议使用此函数。encodedURIComponent