javascript

//SyntaxError: illegal character
function(data, statusText, xhr, $form){ // 有个逗号是中文

The hasOwnProperty() method returns a boolean indicating whether the object has the specified property as its own property(as opposed to inheriting it).

Function.prototype.bind

The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.

var module = {
  x: 42,
  getX: function() {
    return this.x;
  }
}

var retrieveX = module.getX;
console.log(retrieveX()); // The function gets invoked at the global scope
// expected output: undefined

var boundGetX = retrieveX.bind(module);
console.log(boundGetX());
// expected output: 42
fun.bind(thisArg[, arg1[, arg2[, ...]]])

arg1, arg2, ...Arguments to prepend to arguments provided to the bound function when invoking the target function.

array.prototype.splice()

The splice() method changes the contents of an array by removing existing elements and/or adding new elements.

var months = ['Jan', 'March', 'April', 'June'];
months.splice(1, 0, 'Feb');
// inserts at 1st index position
console.log(months);
// expected output: Array ['Jan', 'Feb', 'March', 'April', 'June']

months.splice(4, 1, 'May');
// replaces 1 element at 4th index
console.log(months);
// expected output: Array ['Jan', 'Feb', 'March', 'April', 'May']

array.prototype.slice()

The slice() method returns a shallow copy of a portion of an array into a new array object selected from begin to end (end not included). The original array will not be modified.

var animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];

console.log(animals.slice(2));
// expected output: Array ["camel", "duck", "elephant"]

console.log(animals.slice(2, 4));
// expected output: Array ["camel", "duck"]

console.log(animals.slice(1, 5));
// expected output: Array ["bison", "camel", "duck", "elephant"]
var regex1 = RegExp('foo*');
var regex2 = RegExp('foo*','g');
var str1 = 'table football';

console.log(regex1.test(str1));
// expected output: true

console.log(regex1.test(str1));
// expected output: true

console.log(regex2.test(str1));
// expected output: true
// the regex.prototype.exec() method, the returned array has the matched text as the first item, and then one item for 
// each capturing parenthesis that matched containing the text that was captured. when "g" is absent,lastIndex will remain as 0
// the string.prototype.search() method return the index of the first match.
// the string.prototype.match() method if "g" is absent, return the same result as regex.prototype.exec(), else return an array
// containing all matched substrings rather than match objects. captured groups are not returned.
 console.log(regex2.test(str1)); //if the regex has the global flag set, test() will advance the lastIndex of the regex.// expected output: false
function.prototype.length  // arguments length
function.prototype.toString() // 可以打印函数定义




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值