Skip to content

Instantly share code, notes, and snippets.

@kuruma-gs
Created November 22, 2011 04:33
Show Gist options
  • Save kuruma-gs/1384902 to your computer and use it in GitHub Desktop.
Save kuruma-gs/1384902 to your computer and use it in GitHub Desktop.
merge!
a = {a:1,b:2}
b = {b:3,c:4}
$.extend(a, b)
a #=> {a: 1, b: 3, c: 4}
a = {a:1,b:2}
b = {b:3,c:4}
_.extend(a, b)
a #=> {a: 1, b: 3, c: 4}
a = {a:1,b:{c:2}}
b = {b:{d: 3}}
$.extend(a, b)
a #=> {a: 1, b: {d: 3}}
a = {a:1,b:{c:2}}
b = {b:{d: 3}}
_.extend(a, b)
a #=> {a: 1, b: {d: 3}}
a = {a:1,b:{c:2}}
b = {b:{d: 3}}
$.extend(true, a, b)
a #=> {a: 1, b: {c:2, d: 3}}
a = {a:1,b:2}
b = {b:3,c:4}
a.merge! b
a #=> {:a=>1, :b=>3, :c=>4}
a = {a:1,b:2}
b = {b:3,c:4}
a.merge! b
a #=> {:a=>1, :b=>3, :c=>4}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment