Skip to content

Instantly share code, notes, and snippets.

@searls
Created November 14, 2011 01:00
Show Gist options
  • Save searls/1362999 to your computer and use it in GitHub Desktop.
Save searls/1362999 to your computer and use it in GitHub Desktop.
#looking for some code that won't work? you're in luck!
window.newb = (Constructor) ->
args = Array.prototype.slice.call(arguments, 1)
return ->
Temp = ->
Temp.prototype = Constructor.prototype
inst = new Temp
ret = Constructor.apply(inst, args)
return Object(ret) == ret ? ret : inst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment