// 手写简易版的es6中数组的includes方法
Array.prototype.includes = function (item, index) {var arr = this;var flag = false;if (!arguments[0] || !arguments[1]) return false;for (let i = 0; i < arr.length; i++) { if (!!index) {if ((typeof index == 'string' || typeof index == 'number') && (arr[i] == item && i == index)) { flag = true;break;}} else { if (arr[i] == item) { flag = true;break;}}}return flag;
}
第二篇
// 手写new函数的实现
function _new(Fn, ...args) {var obj = Object.create(Fn.prototype);// obj.__proto = Fn.prototype;var result = Fn.call(obj, ...args);return result != null && (typeof result == 'object' || typeof result == 'function') ? result : obj;
}