随笔分类 - js
摘要:function Evaluate(xpath){ var doc = document.evaluate(xpath,document,null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null) var arr = [] for(var i=0;i <
阅读全文
摘要:1 function compress(url, width, height) { 2 return new Promise((resolve, reject) => { 3 let img = document.createElement('img') 4 img.onload = () => {
阅读全文
摘要:Object.defineProperty(Object.prototype, "test", { enumerable: false, //禁止遍历 value: function (o) { console.log(o) } })
阅读全文
摘要:数据类型的判断 typeof Symbol(); // symbol 有效 typeof ''; // string 有效 typeof 1; // number 有效 typeof true; //boolean 有效 typeof undefined; //undefined 有效 typeof
阅读全文
摘要:实现: Array.prototype.Sum = function (fn) { return eval(this.map(x => Number(typeof fn == "function" ? fn(x) : x)).join("+")) || 0 } 用法示例: var arr1 = [{
阅读全文
摘要:/** * 组件名称 * @module tool.js * @desc 数据分组 * @author DHL * @date 2017年12月05日17:22:43 * @param { Function } func - 方法 * @example 调用示例 * [].groupBy(x=>({
阅读全文
摘要:获取 var GetCookies = () => { var n = [] document.cookie.split(';').forEach(o => { var x = o.split('='); n[x[0].trim()] = x[1] }) return n; } //调用 var c
阅读全文