the hardest exam question
the hardest exam question
await and async
Or car to carpet
Or fun to funeral
It… isn’t poop?
The bot toggle was on for my account for some reason but I am human… I think
It should be off now
Browsers love it!
Practically anything you write will execute without all that scope and well formed statements nonsense.
You’ll find an npm package to help you count up to 2.
(I recently learned - maybe here - that the is-even package has over 170k weekly downloads)
To be fair having a name can make things easier to read. I get that i % 2 == 0 is a common pattern and most programmers will quickly recognize what is happening. But isEven(i) is just that much easier to grok and leaves that brainpower to work on something else.
But I would never import a package for it. I would just create a local helper for something this trivial.
Oh boy, this actually made me laugh out loud
Ajax.
Uhhh…
When my console throws a NaN I kinda think of it as an Halloween kid receiving a fruit instead of a candy. He won’t say “That’s a fruit”. He’ll say “That’s not a treat”.
I’m personally pissed more often by a falsy 0.
Did you know that early analog computers would literally explode when asked to divide by 0?
Now computers just say “Hey stupid, that shit is not even a Number in a mathematical sense, but sure I’ll add one to it.” instead of “Why would you kill me like this?”
You can’t really define Infinity as a number, yet it is part of their world.
So typeof NaN === ‘number’ totally makes sense in that regard.
If you ever worked with arrays of dates, don’t judge NaN too harshly.
in javascript a property is truthy if it exists
myThing.property = "some string" if (myThing.property) { // true // do something }It works with everything except of course for falsy values
myThing.number = someNumberThatShouldNotBeEqualToZero if (myThing.number) { // do something very important with that number that should not be equal to zero } // This can fail at anytime without warningSo you’ve got to be extra careful with that logic when you’re dealing with numbers.
I am not saying it’s wrong though. I’m saying it’s often annoying.
ah ok , I think I write this a bit more verbose when using other languages, instead of
if(thing) { stuff; }I do
if(thing != null) { stuff; }so checking for numbers being truthy & existing didn’t seem like an issue
In the case of a non-existing property, the value would be undefined rather than null.
And while == and != exist in JavaScript, most linters will throw an error and require a === and !== as they should be avoided.
null == undefined // true null === undefined // falseBesides, null is a perfectly valid value for a property, just as 0. Working with API Platform, I couldn’t tell the number of times I used this kind of statement:
if (property || property === null) { // do some stuff }Probably just as much as
if (property || property === 0) { // do some stuff }I am forced to try to get a JS certification.
I am reaching the end of my rope, and starting to think of maybe putting my neck into one.
Isaac Newton said that we see far because we stand on the shoulders of giants.
Javascript is like standing on the shoulders of dwarves with brittle bone disease.