Without looking:
'1. null === undefined: ' + false; '2. null == undefined: ' + true; '3. 2+"4": ' + '24'; '4. 2-"3": ' + -1; '5. ""+2: ' + '2'; '6. +"2": ' + 2;
I love these! I even have a codepen that's kind of like this
Oh, yeah, I know my weird Javascript math 🎉
1 and 2 I know because of work since null and undefined can be a pain when testing. 3 is string concatination with 2 being made a string to make it magically work. 4 is making the string a number to make the math operator magically work. 5 is similar to 3 in that it's concatinating an (empty) string with a number that magically becomes a string. 6 is fun because + is the shorthand for type converting to an int.
+
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Without looking:
I love these! I even have a codepen that's kind of like this
Oh, yeah, I know my weird Javascript math 🎉
1 and 2 I know because of work since null and undefined can be a pain when testing.
3 is string concatination with 2 being made a string to make it magically work.
4 is making the string a number to make the math operator magically work.
5 is similar to 3 in that it's concatinating an (empty) string with a number that magically becomes a string.
6 is fun because
+
is the shorthand for type converting to an int.