Skip to content

Instantly share code, notes, and snippets.

@yuanchuan
Created January 13, 2011 04:45
Show Gist options
  • Save yuanchuan/777411 to your computer and use it in GitHub Desktop.
Save yuanchuan/777411 to your computer and use it in GitHub Desktop.
function new_array(/* length */ len, /* default */ value) {
var len = ~~len;
return value
? new Array ( len + 1 ).join( value ).split( '' )
: new Array ( len );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment