Function.prototype.apply()
git
fun.apply(thisArg, [argsArray])数组
Function.prototype.call()
:
fun.call(thisArg[, arg1[, arg2[, ...]]])app
Number.prototype.toFixed()
:
numObj.toFixed(digits) 转换成小数模式,参数为小数点位数this
Number.prototype.toString()
:
numObj.toString(radix) 转换成字符串,参数为进制数prototype
Object.prototype.hasOwnProperty()
返回true or false,对原型链中属性返回falsecode
如下Object属性为ESC5属性Object.keys()
返回kay组成的数组regexp
Object.freeze()
冻结一个对象,使其不可被操做对象
Object.create()
Object.create(proto [, propertiesObject ])
根据特定原型建立新对象继承
使用Object.create实现的继承索引
// Shape - superclass function Shape() { this.x = 0; this.y = 0; } // superclass method Shape.prototype.move = function(x, y) { this.x += x; this.y += y; console.info("Shape moved."); }; // Rectangle - subclass function Rectangle() { Shape.call(this); // call super constructor. } // subclass extends superclass Rectangle.prototype = Object.create(Shape.prototype); Rectangle.prototype.constructor = Rectangle; var rect = new Rectangle(); rect instanceof Rectangle // true. rect instanceof Shape // true. rect.move(1, 1); // Outputs, "Shape moved."
RegExp.prototype.exec()
返回结果数组或null
RegExp.prototype.test()
返回true or false
String.prototype.charAt(index)
返回特定索引的字符
String.prototype.indexOf()
str.indexOf(searchValue[, fromIndex])
返回特定字符的位置索引
"Blue Whale".indexOf("Blue"); // returns 0 "Blue Whale".indexOf("Blute"); // returns -1 "Blue Whale".indexOf("Whale", 0); // returns 5 "Blue Whale".indexOf("Whale", 5); // returns 5 "Blue Whale".indexOf("", 9); // returns 9 "Blue Whale".indexOf("", 10); // returns 10 "Blue Whale".indexOf("", 11); // returns 10
反向为String.prototype.lastIndexOf()
String.prototype.match(regexp)
根据正则查询,返回查询结果数组
String.prototype.replace()
str.replace(regexp|substr, newSubStr|function[, flags]);
返回替换过的新数组
String.prototype.slice()
str.slice(beginSlice[, endSlice])
相似Array的slice,返回字符串片断
String.prototype.split()
str.split([separator][, limit])
字符串打散为数组
var digits = '0123456789' var a = digits.split('',5) //return ['0','1','2','3','4']
如下ESC5属性String.prototype.trim()
裁切先后空格
整理自
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects