Last active
December 14, 2023 00:49
-
-
Save goldo/2b1abf3f1f657e63e9a870f4877da80d to your computer and use it in GitHub Desktop.
Revisions
-
goldo renamed this gist
Nov 21, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
goldo revised this gist
Nov 21, 2016 . 1 changed file with 2 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,43 +1,38 @@ // Tests with Lodash 4.16.4 // Thanks to http://stackoverflow.com/questions/19965844/lodash-difference-between-extend-assign-and-merge _.assignIn ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'bb' } _.merge ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'bb' } _.defaults ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'a' } _.defaultsDeep({}, { a: 'a' }, { a: 'bb' }) // => { a: 'a' } --- _.assignIn ({}, { a: 'a' }, { a: undefined }) // => { a: undefined } _.merge ({}, { a: 'a' }, { a: undefined }) // => { a: 'a' } _.defaults ({}, { a: undefined }, { a: 'bb' }) // => { a: 'bb' } _.defaultsDeep({}, { a: undefined }, { a: 'bb' }) // => { a: 'bb' } --- _.assignIn ({}, {a:{a:'a'}}, {a:{b:'bb'}}) // => { a: { b: 'bb' } } _.merge ({}, {a:{a:'a'}}, {a:{b:'bb'}}) // => { a: { a: 'a', b: 'bb' } } _.defaults ({}, {a:{a:'a'}}, {a:{b:'bb'}}) // => { a: { a: 'a' } } _.defaultsDeep({}, {a:{a:'a'}}, {a:{b:'bb'}}) // => { a: { a: 'a', b: 'bb' } } --- _.assignIn ({}, {a:['a']}, {a:['bb']}) // => { a: [ 'bb' ] } _.merge ({}, {a:['a']}, {a:['bb']}) // => { a: [ 'bb' ] } _.defaults ({}, {a:['a']}, {a:['bb']}) // => { a: [ 'a' ] } _.defaultsDeep({}, {a:['a']}, {a:['bb']}) // => { a: [ 'a' ] } --- _.assignIn ([], ['a'], ['bb']) // => [ 'bb' ] _.merge ([], ['a'], ['bb']) // => [ 'bb' ] _.defaults ([], ['a'], ['bb']) // => [ 'a' ] _.defaultsDeep([], ['a'], ['bb']) // => [ 'a' ] _.assignIn ([], ['a','b'], ['bb']) // => [ 'bb', 'b' ] _.merge ([], ['a','b'], ['bb']) // => [ 'bb', 'b' ] _.defaults ([], ['a','b'], ['bb']) // => [ 'a', 'b' ] @@ -62,5 +57,3 @@ _.assignIn({ 'a': 0 }, new Foo, new Bar); // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } _.assign({ 'a': 0 }, new Foo, new Bar); // => { 'a': 1, 'c': 3 } -
goldo revised this gist
Nov 21, 2016 . 1 changed file with 23 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,14 +32,35 @@ _.defaultsDeep({}, {a:['a']}, {a:['bb']}) // => { a: [ 'a' ] } --- _.assign ([], ['a'], ['bb']) // => [ 'bb' ] _.assignIn ([], ['a'], ['bb']) // => [ 'bb' ] _.merge ([], ['a'], ['bb']) // => [ 'bb' ] _.defaults ([], ['a'], ['bb']) // => [ 'a' ] _.defaultsDeep([], ['a'], ['bb']) // => [ 'a' ] _.assign ([], ['a','b'], ['bb']) // => [ 'bb', 'b' ] _.assignIn ([], ['a','b'], ['bb']) // => [ 'bb', 'b' ] _.merge ([], ['a','b'], ['bb']) // => [ 'bb', 'b' ] _.defaults ([], ['a','b'], ['bb']) // => [ 'a', 'b' ] _.defaultsDeep([], ['a','b'], ['bb']) // => [ 'a', 'b' ] --- // _.assign vs _.assignIn function Foo() { this.a = 1; } function Bar() { this.c = 3; } Foo.prototype.b = 2; Bar.prototype.d = 4; _.assignIn({ 'a': 0 }, new Foo, new Bar); // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } _.assign({ 'a': 0 }, new Foo, new Bar); // => { 'a': 1, 'c': 3 } -
goldo revised this gist
Nov 21, 2016 . 2 changed files with 45 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ // Lodash 4.16.4 _.assign ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'bb' } _.assignIn ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'bb' } _.merge ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'bb' } _.defaults ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'a' } _.defaultsDeep({}, { a: 'a' }, { a: 'bb' }) // => { a: 'a' } --- _.assign ({}, { a: 'a' }, { a: undefined }) // => { a: undefined } _.assignIn ({}, { a: 'a' }, { a: undefined }) // => { a: undefined } _.merge ({}, { a: 'a' }, { a: undefined }) // => { a: 'a' } _.defaults ({}, { a: undefined }, { a: 'bb' }) // => { a: 'bb' } _.defaultsDeep({}, { a: undefined }, { a: 'bb' }) // => { a: 'bb' } --- _.assign ({}, {a:{a:'a'}}, {a:{b:'bb'}}) // => { a: { b: 'bb' } } _.assignIn ({}, {a:{a:'a'}}, {a:{b:'bb'}}) // => { a: { b: 'bb' } } _.merge ({}, {a:{a:'a'}}, {a:{b:'bb'}}) // => { a: { a: 'a', b: 'bb' } } _.defaults ({}, {a:{a:'a'}}, {a:{b:'bb'}}) // => { a: { a: 'a' } } _.defaultsDeep({}, {a:{a:'a'}}, {a:{b:'bb'}}) // => { a: { a: 'a', b: 'bb' } } --- _.assign ({}, {a:['a']}, {a:['bb']}) // => { a: [ 'bb' ] } _.assignIn ({}, {a:['a']}, {a:['bb']}) // => { a: [ 'bb' ] } _.merge ({}, {a:['a']}, {a:['bb']}) // => { a: [ 'bb' ] } _.defaults ({}, {a:['a']}, {a:['bb']}) // => { a: [ 'a' ] } _.defaultsDeep({}, {a:['a']}, {a:['bb']}) // => { a: [ 'a' ] } --- _.assign ([], ['a'], ['bb']) // => [ 'bb' ] _.assignIn ([], ['a'], ['bb']) // => [ 'bb' ] _.merge ([], ['a'], ['bb']) // => [ 'bb' ] _.defaults ([], ['a'], ['bb']) // => [ 'a' ] _.defaultsDeep([], ['a'], ['bb']) // => [ 'a' ] _.assign ([], ['a','b'], ['bb']) // => [ 'bb', 'b' ] _.assignIn ([], ['a','b'], ['bb']) // => [ 'bb', 'b' ] _.merge ([], ['a','b'], ['bb']) // => [ 'bb', 'b' ] _.defaults ([], ['a','b'], ['bb']) // => [ 'a', 'b' ] _.defaultsDeep([], ['a','b'], ['bb']) // => [ 'a', 'b' ] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +0,0 @@ -
goldo created this gist
Nov 21, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ // Lodash 4.16.4 ``` n_ > _.assign ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'bb' } n_ > _.assignIn ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'bb' } n_ > _.merge ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'bb' } n_ > _.defaults ({}, { a: 'a' }, { a: 'bb' }) // => { a: 'a' } n_ > _.defaultsDeep({}, { a: 'a' }, { a: 'bb' }) // => { a: 'a' } ```