Created
March 23, 2017 21:27
-
-
Save yannickglt/e59f8949ab07cae8254d4259545be532 to your computer and use it in GitHub Desktop.
Pure javascript addition vs Lo-Dash add method
This file contains 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 characters
// With "+" operator | |
1 + undefined | |
// NaN | |
undefined + undefined | |
// NaN | |
"1" + "2" | |
// "12" | |
1 + "2" | |
// "12" | |
1 + {} | |
// 1[object Object] | |
1 + [2, 3] | |
// "12, 3" | |
// With Lo-Dash | |
_.add(1, undefined) | |
// 1 | |
_.add(undefined, undefined) | |
// 0 | |
_.add("1", "2") | |
// 3 | |
_.add(1, "2") | |
// 3 | |
_.add(1, {}) | |
// NaN | |
_.add(1, [2, 3]) | |
// NaN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment