理解endpoint的概念 def 方法名
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
<!--a.html--> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<p>parent</p> | |
<iframe src="b.html" onload="resizeIframe(this)"></iframe> | |
<p></p> |
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
//创建一个n长的空格字符串 | |
Array(n).join(' ') | |
//判断Object是否为空 | |
Object.keys(obj) === 0 | |
//判断是否为PlainObject(不为window,Node等) | |
function isObject(val) { | |
return Object == val.constructor; | |
} |
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 fs = require('fs'); | |
var readFile = function (fileName){ | |
return new Promise(function (resolve, reject){ | |
fs.readFile(fileName, function(error, data){ | |
if (error) reject(error); | |
resolve(data); | |
}); | |
}); | |
}; |
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
/* | |
参考链接 http://www.ruanyifeng.com/blog/2015/05/thunk.html | |
js中 thunk 的概念及函数式编程中所说的柯里化 | |
JavaScript 语言是传值调用,它的 Thunk 函数含义有所不同。在 JavaScript 语言中,Thunk 函数替换的不是表达式,而是多参数函数,将其替换成单参数的版本,且只接受回调函数作为参数 | |
*/ | |
/*例子一*/ | |
// 正常版本的readFile(多参数版本) | |
fs.readFile(fileName, callback); |
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 mult = function(){ | |
var a = 1; | |
for(var i = 0, l = arguments.length; i < l; i++) { | |
a = a * arguments[i]; | |
} | |
return a; | |
} | |
var proxyMulti = (function(){ | |
var cache = {}; |
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
jQuery.extend = jQuery.fn.extend = function() { | |
var options, name, src, copy, copyIsArray, clone, | |
target = arguments[ 0 ] || {}, | |
i = 1, | |
length = arguments.length, | |
deep = false; | |
// Handle a deep copy situation | |
if ( typeof target === "boolean" ) { | |
deep = target; |
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
匹配单纯的tag: /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/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
//延长xss生命周期 | |
//文章:http://drops.wooyun.org/web/5049 | |
var XssGhost = function() { | |
function module(id, payload, winList, first) { | |
var window = this; | |
// debug | |
window.addEventListener('error', function(e) { |
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
//from seajs | |
function isType(type) { | |
return function(obj) { | |
return {}.toString.call(obj) == "[object " + type + "]" | |
} | |
} | |
var isObject = isType("Object") | |
var isString = isType("String") | |
var isArray = Array.isArray || isType("Array") |