理解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
//创建一个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
<!--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
document.addEventListener('WeixinJSBridgeReady', function(){ | |
//如果执行到这块的代码,就说明是在微信内部浏览器内打开的. | |
alert('当前页面在微信内嵌浏览器中打开!'); | |
}); |
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
// This function: | |
function foo() { | |
var x = 5; | |
var y = 6; | |
debugger; | |
return x + y; | |
} |
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://krasimirtsonev.com/blog/article/Javascript-template-engine-in-just-20-line | |
//https://segmentfault.com/a/1190000005705169 | |
var TemplateEngine = function(html, options) { | |
var re = /<%([^%>]+)?%>/g, reExp = /(^( )?(if|for|else|switch|case|break|{|}))(.*)?/g, code = 'var r=[];\n', cursor = 0, match; | |
var add = function(line, js) { | |
js? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') : | |
(code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : ''); | |
return add; | |
} |
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
//Lets create a simple particle system in HTML5 canvas and JS | |
//Initializing the canvas | |
var canvas = document.getElementById("canvas"); | |
var ctx = canvas.getContext("2d"); | |
//Canvas dimensions | |
var W = 500; var H = 500; | |
//Lets create an array of particles |
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
/** | |
* Hilo | |
* Copyright 2015 alibaba.com | |
* Licensed under the MIT License | |
*/ | |
/** | |
* @language=en | |
* Create Example Class: | |
* <pre> |
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
https://github.com/ded/klass/blob/master/klass.js |
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
crypto.createHash('md5').update(text).digest('hex') |