Skip to content

Instantly share code, notes, and snippets.

@zhanhongtao
Created July 23, 2014 12:29
Show Gist options
  • Save zhanhongtao/03d24d0076810eb38b58 to your computer and use it in GitHub Desktop.
Save zhanhongtao/03d24d0076810eb38b58 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
var jsonpcallback = (function() {
var id = 0;
var prefix = '_json_p_' + ('' + Math.random()).slice( 2, 8 );
var noop = function() {};
return function(cb) {
var name = prefix + (++id);
this[ name ] = typeof cb === 'function' ? cb : noop;
return name;
};
})();
var partial = function( cb ) {
var argus = [].slice.call( arguments, 1 );
return function() {
return cb.apply( null, argus.concat( [].slice.call(arguments) ) );
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment