摘要: var str = "url(../images/kk.png)"; var pattern = /\w+\.\w{3}/g; console.log(str.match(pattern)[0]); // 'kk.png' 阅读全文
posted @ 2017-07-05 15:45 ax=null 阅读(821) 评论(0) 推荐(0) 编辑
摘要: function Person(name) { this.name = name; this.flag = 0; Object.defineProperty(this, 'name', { get: function() { return name;}, set: function(newName) { if (this.flag) { n... 阅读全文
posted @ 2017-07-03 20:02 ax=null 阅读(113) 评论(0) 推荐(0) 编辑
摘要: function Person(name) { this.name = name; Object.defineProperty(this, 'name', { get: function() { return name;}, set: function(newName) { if (name) { return;} return name = n... 阅读全文
posted @ 2017-07-03 19:24 ax=null 阅读(126) 评论(0) 推荐(0) 编辑
摘要: var o = Object.create(null); console.log(o); // {} console.log(o.constructor); // undefined console.log(o.__proto__); // undefined console.log(o instanceof Object); // false 阅读全文
posted @ 2017-06-22 21:47 ax=null 阅读(259) 评论(0) 推荐(0) 编辑
摘要: var a = {}; var b = a; var o = {}; o[a] = 1; o[b] = 2; o[a]++; console.log(o[b]); 阅读全文
posted @ 2017-06-09 12:03 ax=null 阅读(114) 评论(0) 推荐(0) 编辑
摘要: var closure = (function(){ var arr = [1, 3]; function printArr() { console.log(arr); }; return [arr, printArr]; }()); closure[1](); // [1, 3] closure[0][1] = 2; closure[1](... 阅读全文
posted @ 2017-06-09 01:20 ax=null 阅读(117) 评论(0) 推荐(0) 编辑
摘要: var closure = (function(){ var arr = [1, 3]; return { getA: (function() { return arr; }()), printArr: function() { console.log(arr); }... 阅读全文
posted @ 2017-06-09 01:14 ax=null 阅读(94) 评论(0) 推荐(0) 编辑
摘要: var closure = (function(){ var arr = [1, 3]; return { getA: function() { return arr; }, printArr: function() { console.log(arr); } ... 阅读全文
posted @ 2017-06-09 01:11 ax=null 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 如何判断 instanceof 返回真 只要判断右边的值是否是左边对象的构造函数或原型对象上的构造函数即可 // example var arr = []; 由于: 1. arr.constructor === Array 2. arr.__proto__ === Array.prototype 3. arr.__poto__.proto__ === Object.prototype 所... 阅读全文
posted @ 2017-06-09 01:00 ax=null 阅读(1890) 评论(0) 推荐(0) 编辑
摘要: function selectSort(arr) { var len = arr.length; for (var i = 0; i arr[j]) { var temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; }... 阅读全文
posted @ 2017-06-07 21:33 ax=null 阅读(139) 评论(0) 推荐(0) 编辑