ReactDOM.render 1. render 多次子组件时,getInitialState 触发多次 2. render 多次子组件时,getDefaultProps 触发一次 Read More
posted @ 2016-07-25 15:59 koala_熊 Views(108) Comments(0) Diggs(0) Edit
// 单向链表 function LinkedList() { this.head = {element: 'head', next: null}; this.node = function (node) {return {element: node, next: null}}; // 查找 this.find = function (node) { ... Read More
posted @ 2016-07-18 13:42 koala_熊 Views(113) Comments(0) Diggs(0) Edit
// set实现数组去重 function dedupe(arr) { return Array.from(new Set(arr)); } Read More
posted @ 2016-07-16 11:10 koala_熊 Views(86) Comments(0) Diggs(0) Edit
var obj = new BinaryTree(); obj.add(0); obj.add(2); obj.add(1); obj.add(3); obj.add(4); obj.add(8); obj.add(1); obj.add(-3); obj.add(-2); obj.add(-7); Read More
posted @ 2016-07-12 18:03 koala_熊 Views(128) Comments(0) Diggs(0) Edit
function mulBase(n, base) { var base16 = [{10: 'A'}, {11: 'B'}, {12: 'C'}, {13: 'D'}, {14: 'E'}, {15: 'F'}]; var arr = []; var res = ''; while (n > 0) { arr.push(n % base); ... Read More
posted @ 2016-07-08 16:05 koala_熊 Views(116) Comments(0) Diggs(0) Edit
// 创建二维数组 Array.matrix = function (rows, cols, initial) { var arr = []; for (var i = 0; i < rows; i++) { var column = []; for (var j = 0; j < cols; j++) { column[j... Read More
posted @ 2016-07-07 18:48 koala_熊 Views(115) Comments(0) Diggs(0) Edit
// (来自JavaScript高级程序设计) 自定义事件 function EventTarget() { this.handler = {}; } EventTarget.prototype = { constructor: EventTarget, // 添加事件 addHandler: function (type, fn) { i... Read More
posted @ 2016-07-06 15:56 koala_熊 Views(221) Comments(0) Diggs(0) Edit
// (来自JavaScript高级程序设计) 自定义事件 function EventTarget() { this.handler = {}; } EventTarget.prototype = { constructor: EventTarget, // 添加事件 addHandler: function (type, fn) { i... Read More
posted @ 2016-07-06 14:36 koala_熊 Views(134) Comments(0) Diggs(0) Edit
// (来自)JavaScript高级程序设计 不支持匿名函数 function throttle(fn, context) { clearTimeout(fn.tId); fn.tId = setTimeout(function () { fn.call(context); }, 100); } // (来自)百度 不支持匿名函数 function ... Read More
posted @ 2016-07-05 20:03 koala_熊 Views(101) Comments(0) Diggs(1) Edit
'use strict'; // 获取CSS function getStyle(obj, attr) { return (obj.currentStyle || getComputedStyle(obj, false))[attr]; } // 设置CSS function setStyle(obj, attr, val) { switch (typeof attr) ... Read More
posted @ 2016-06-30 11:47 koala_熊 Views(1329) Comments(0) Diggs(0) Edit