10 2017 档案
摘要:{ // 长轮询 let ajax=function* (){ yield new Promise(function(resolve,reject){ setTimeout(function () { resolve({code:0}) }, 200); }) } let pull=function(){ le...
阅读全文
摘要:function getExplorer() { var explorer = window.navigator.userAgent; //ie if (explorer.indexOf("MSIE") >= 0) { return 'ie'; } ...
阅读全文
摘要:转自:CTOLib , www.ctolib.com/topics-107352.html ggraph - 图形可视化的凌乱数据 转自:CTOLib , www.ctolib.com/topics-107352.html ggraph - 图形可视化的凌乱数据 转自:CTOLib , www.ct
阅读全文
摘要:/* 获取当前环境: 系统环境: iOS Android PC 浏览器环境 微信内置浏览器、QQ内置浏览器、正常浏览器 是否app内打开 */ var ua = navigator.userAgent.toLowerCase(); //获取浏览器标识并转换为小写 var curConfig = { isiOS: !!navigator.userAgent....
阅读全文
摘要:Iterator遍历器 遍历器(Iterator)就是这样一种机制。它是一种接口,为各种不同的数据结构提供统一的访问机制。任何数据结构只要部署Iterator接口,就可以完成遍历操作(即依次处理该数据结构的所有成员)。 作用: 为各种数据结构,提供一个统一的、简便的访问接口 使得数据结构的成员能够按
阅读全文
摘要:{ // 基本定义 let ajax = function(callback) { console.log('执行'); //先输出 1 执行 setTimeout(function() { callback && callback.call() }, 1000); }; ajax(funct...
阅读全文
摘要:{ // 基本定义和生成实例 class Parent{ constructor(name='mukewang'){ this.name=name; } } let v_parent1=new Parent(); let v_parent2=new Parent('v'); console.log('构造函数和实例',v_parent1,v_p...
阅读全文
摘要:{ //原始对象 let obj={ time:'2017-03-11', name:'net', _r:123 }; //(代理商)第一个参数代理对象,第二个参数真正代理的东西 let monitor=new Proxy(obj,{ // 拦截对象属性的读取 get(target,key){ return target...
阅读全文
摘要:1 用户名正则 //用户名正则,4到16位(字母,数字,下划线,减号) var uPattern = /^[a-zA-Z0-9_-]{4,16}$/; //输出 true console.log(uPattern.test("iFat3")); 2 密码强度正则 //密码强度正则,最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符 var pPattern = /^.*(?=...
阅读全文
摘要:function testNumber(){ var yourinputValue=$("#yourinputId").val(); var reg = /^[1-9]\d*$/; alert(reg.test(yourinputValue)) }
阅读全文
摘要://数据结构对比 增查改删 { //map、set和Object let item = {t:1}; let map = new Map(); let set = new Set(); let obj = {}; //增 map.set('t',1); set.add(item); obj['t'] = 1; co...
阅读全文
摘要://数据结构对比 增查改删 { //map和array对比 let map = new Map(); let array = []; //增 map.set('t',1); array.push({t:1}); console.info('map-array',map,array) //{"t"=>1};-[0:{t:1}] ...
阅读全文
摘要:{ let list = new Set(); list.add(5); list.add(7); console.log('size', list, list.size); //{5, 7} 2 } { let arr = [1, 2, 3, 4, 5]; let list = new Set(arr); console.log('...
阅读全文
摘要:function hrefObj() { var localhref = window.location.href; var localarr = localhref.split('?')[1].split('&'); console.log(localarr) var tempObj = {};
阅读全文
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.or
阅读全文
摘要:var day1 = new Date("2017-9-17"); var day2 = new Date("2017-10-18"); console.log((day2 - day1) / (1000 * 60 * 60 * 24));
阅读全文
摘要:function tab(date1,date2){ var oDate1 = new Date(date1); var oDate2 = new Date(date2); if(oDate1.getTime() > oDate2.getTime()){ console.log('第一个大'); } else { console.l...
阅读全文
摘要:{ // 声明 let a1 = Symbol(); let a2 = Symbol(); console.log(a1 === a2); //false let a3 = Symbol.for('a3'); let a4 = Symbol.for('a3'); console.log(a3 === a4); //true } { ...
阅读全文
摘要:getBeforeDate: function(day, str) { var now = new Date().getTime(); //获取毫秒数 var before = new Date(now - ((day > 0 && day ? day : 0) * 86400 * 1000)); var year = before.getFullYear(); var month = befo...
阅读全文
摘要:{ //简洁表示法 let o = 1; let k = 2; let es5 = { o:o, k:k }; let es6 = { o,k }; console.log(es5,es6); //1,2;1,2 let es5_method = { hell...
阅读全文
摘要://函数参数默认值(more值后不能有参数) { function test(x,y = 'world'){ console.log('默认值',x,y); } test('hello');// hello world test('hello','kill'); //hello kill } //作用域概念 { let x = 'te...
阅读全文
摘要:Document t1 点击获取ip click me
阅读全文