If you’re interested in exploring these quirks further, here is a resource that includes a quiz, which covers many of them at jsisweird.com.
===). The triple equals compares the value and make sure that both items are of the same type. This fixes the problem.
BigInt type. Fortunately, it was adopted quickly and as of this recording has almost 90% penetration in the browser space.
If you’re dealing with large numbers, you may get unexpected behavior. The introduction of
n to indicate that a number is a primitive type
The parameters in the declaration are a shortcut to make it easier to get at what was passed in, but they don’t change the execution. They’re there to make your life easier, that’s it. There’s a neat feature, which I haven’t shown you, though, which is the
arguments variable, which you can get at to see all of the arguments passed in.
!), or bang, is the NOT operator. Using it twice like this is a shortcut to convert a value to Boolean.
03:55 The first time you NOT something will convert it to Boolean and negate it. The second time you NOT something will invert it. And of course, if you’re inverting the negated thing, you get a Boolean of the same value as the thing passed in. Now let me call it.
Calling the function without arguments will result in an
undefined converts to
Look at that! Math. You may have heard me use the phrase “array-like” when I spoke of the
arguments value. I did that on purpose. It isn’t an array. It is iterable, and as you’ve seen here, it can be restructured. But unlike an
Array object, it doesn’t support
.reduce() or any of the other
null. If you send
undefined instead, you’d have no way of distinguishing between that case and the argument being left off altogether. With default arguments available in ES6, the importance of
null is waning.
Become a Member to join the conversation.