Skip to content

Instantly share code, notes, and snippets.

View evensandbox's full-sized avatar
😀
Out sick

redky evensandbox

😀
Out sick
View GitHub Profile
@evensandbox
evensandbox / type.js
Last active December 22, 2015 08:49
type
function type(s) {
return Object.prototype.toString.call(s).slice(8,-1).toLowerCase();
}
console.assert( type( null ) == 'null', 'null' );
console.assert( type( undefined ) == 'undefined', 'undefined' );
console.assert( type( [] ) == 'array', '[]' );
console.assert( type( {} ) == 'object', 'object' );
console.assert( type( false ) == 'boolean', 'false' );
console.assert( type( 1.2 ) == 'number', '1.2' );
@evensandbox
evensandbox / gist:6445945
Created September 5, 2013 04:01
partial
// partial
;(function() {
var BASE_FONT_SIZE = 100;
var zoom = partial(function( a, b ) {
return a + b;
}, BASE_FONT_SIZE );
var result = zoom( -30 ); // 70
var result2 = zoom( 50 ); // 150
@evensandbox
evensandbox / auto-run.js
Last active December 22, 2015 06:49
匿名函数
// 自执行函数
;(function() {
//...
})();
// dom 绑定.
document.onclick = function () {
// ....
};
@evensandbox
evensandbox / define_function.js
Last active December 22, 2015 06:49
函数定义和函数调用
// 函数声明
function _name() {
//...
}
// 函数表达式
var _name = function() {
//...
};