Skip to content

Instantly share code, notes, and snippets.

@frostney
Created November 29, 2012 19:07
Show Gist options
  • Save frostney/4171169 to your computer and use it in GitHub Desktop.
Save frostney/4171169 to your computer and use it in GitHub Desktop.
jQuery-like extend in Coffeescript
extend = (target, objects...) ->
for obj in objects
for key, value of obj
target[key] = value
target
# One object
a = extend {}, {test: 5}
alert JSON.stringify(a)
# More than one object
b = extend {}, a, {test2: 8}, {test3: 12}
alert JSON.stringify(b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment