This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Object.prototype[Symbol.iterator] = function() { | |
| var self = this; | |
| var keys = Object.keys(this); | |
| var l = keys.length; | |
| var i = -1; | |
| return { | |
| next: function() { | |
| i++; | |
| var done = i >= l; | |
| var key = keys[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var assert = require('assert'); | |
| var util = require('util'); | |
| function on(thisArg, eventName, fn, isOnce, isPrepend) { | |
| assert(eventName && typeof fn === 'function', 'Need eventName and callback function'); | |
| if (eventName !== 'newListener' || thisArg.listenerCount('newListener')){ | |
| thisArg.emit('newListener', eventName, fn); | |
| } | |
| if (thisArg.fns[eventName]) { | |
| if (thisArg.fns[eventName].length < thisArg.getMaxListeners()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var person = { | |
| name : { | |
| first : 'ye', | |
| last : 'lin' | |
| }, | |
| age : 28, | |
| gender : 'male', | |
| birth : { | |
| year : 1987, | |
| month : 6, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function(){ | |
| var _ = {}; | |
| _.now = Date.now || function(){ | |
| return new Date().getTime(); | |
| }; | |
| // Returns a function, that, when invoked, will only be triggered at most once | |
| // during a given window of time. Normally, the throttled function will run | |
| // as much as it can, without ever going more than once per `wait` duration; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function format(num){ | |
| return (num.toFixed(2) + '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 网页可见区域宽:window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth | |
| 网页可见区域高:window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight | |
| 文档高度:document.body.scrollHeight | |
| 文档被滚动高度:document.body.scrollTop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function add() { | |
| let sum = 0; | |
| Array.from(arguments).forEach(v => sum += v); | |
| function f() { | |
| Array.from(arguments).forEach(v => sum += v); | |
| return f; | |
| } | |
| f.toString = f.valueOf = function() { | |
| return +sum; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //运行插入页面的javascript代码 | |
| function loadScriptString(s){ | |
| var a = document.createElement('script'); | |
| a.type = 'text/javascript'; | |
| var t = document.createTextNode(s); | |
| try{ | |
| a.appendChild(t); | |
| }catch(e){ | |
| a.text = s; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function lunarLeapMonthOfYear(year){ | |
| var table=[ | |
| 0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0, | |
| 0x055d2,0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2, | |
| 0x095b0,0x14977,0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60, | |
| 0x09570,0x052f2,0x04970,0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60, | |
| 0x186e3,0x092e0,0x1c8d7,0x0c950,0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4, | |
| 0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,0x06ca0,0x0b550,0x15355,0x04da0, | |
| 0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x06aa0,0x0aea6,0x0ab50,0x04b60, | |
| 0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,0x096d0,0x04dd5, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getXHR(){ | |
| var xmlHttp = null; | |
| try { | |
| // Firefox, Opera 8.0+, Safari | |
| xmlHttp = new XMLHttpRequest(); | |
| } catch (e) { | |
| // Internet Explorer | |
| try { | |
| xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); | |
| } catch (e) { |
NewerOlder