In a video I published a few weeks ago, I made a rather basic mistake.
Given the following variables...
let threeString = "3"; let threeNum = 3;
What does this expression evaluate to?
threeString + threeNum
If you're smarter than I was an hour ago, you'll know that it evaluates to
According to ECMAScript, as summarized by Valentino:
If x is String or y is String then return ToString(x) followed by ToString(y)
In other words, if there is an expression with the + operator, and one of the values is a string, it will always coerce the values into a string.
If you want to see my mistake in action, check out the video below!
And the follow up video, which I made before this mistake I made was pointed out...