Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Because undefined means any result is OK.
If you had been using C/C++, the compiler would have made that faster by optimising the undefined function away. Or maybe even the whole program. -
kamen69845yMaybe you should be asking yourself why that something is undefined and why you don't have a check for that.
-
C0D4681465yJavaScript does wierd things if you let it.
Go back and check "something" is actually an expected value / type before making use of it. -
@Fast-Nop I would hope the compiler just optimises the developer away in that scenario.
-
Root825085yUndefined behavior is undefined behavior.
The language doesn't replace you as the developer -- and shouldn't strive to. -
-
kamen69845y@kolaente Then maybe your check isn't the best. Care to share a more specific code example?
-
kamen69845y@kolaente I'm not even blaming or accusing you or whatever, I'm just curious what's happening, maybe I can learn something new from it too.
-
@rendezvous
JS always has everything defined.
Since when JS is a strongly typed lang? If you can have a var that can change types mid run then you might crash the code by putting shit in that var. You wouldnt be able to change the type in the strongly typed lang.
Please explain if i understood something incorrectly. -
@kamen So, this is a vue js app where I set some element when the user clicks on a thing. This thing is draggable, when the user then stops dragging it a function gets called to do some calculations based on where it was dragged, based on the element which was set when the user clicked. Sometimes, the element is not set when the user finishes dragging (I suspect because of a race condition or something like that), so to be sure the element is set, I have a loop in the drag handler which waits until the element is not null/undefined. And that one does not work.
The code is here: https://kolaente.dev/vikunja/...
(Sorry for being unresponsive, I was busy with other stuff) -
kamen69845y@kolaente I'm not familiar with Vue, but I'd suggest looking into reasons why the mouse up event doesn't fire.
Related Rants
God I hate JavaScript.
Why on earth would some variable * somthing.other (where somthing is undefined) result in 653957364??????
rant
js
nan