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
-
hexc11196yI don't like JS but one thing that helped be learn it faster was using a browser console and checking type/etc using that.
-
Nevoic1996y@D--M do you tell people who complain about writing code in assembly/C this?
You can always write better code, but some languages are more modern/better to work with for everyday use. JS is definitely dated and shitty to work with, as are most dynamically typed languages. -
rant1ng44626y@D--M
I'm still a bit new to modern javascript/frontend, only a few years experience
seems to me javascript has a lot of gotchas
sure, if I became an expert at js, I could see how to maybe exploit all these funny ways it handles datatypes and scopes
but I just don't get the use of, for example, 5 different ways to say "false" or null.. it just makes things a huge headache sometimes
none of it is intuitively obvious, it's quirky and, very much feels to me like "features" and not "bugs" if you get my drift
but whatever, in a way you're right, a language is a language and a good coder masters it eventually -
rant1ng44626y@Nevoic
I mean, I guess with javascript, you have got to REALLY control what values your variables may end up having.
of course, that's so easy to do in a web environment where connections fail, each client has a choice of like 8 browsers and 50 different version of said browsers over the past decade, etc.
so yeah, you really gotta be a genius I guess
cuz that's what we all should be doing
keeping strict control on our javascript variable datatypes.....AND scopes, manually, in our heads, because we always know what will happen in these environments.
or, just do this:
let $varr = whatever;
self = this;
somefunction () {
if($this.varr == null || $this.varr === null && $this.varr !== undefined && $this.varr !== '')
return $some.headaches;
}
*wipes hands*
problem solved. first try, too. -
rant1ng44626y@AngryMTUDev
I'm reading about it... seems interesting
maybe a little overkill for my current needs, but i'll keep it in mind, thanks -
Phlisg25166yalways compare with === (yes, three of them :D), == converts the type
"" is considered a falsy, 0 is falsy, so 0 == "" is true (type in the console !!"" and !!0 to reflect boolean value)
but "" === 0 returns false, as they're not the same type.
" " !== "" as it isn't the same string
I think that knowing all this in the end helps a lot in writing elegant code or making it stronger when you need it
Or you could always convert to boolean using !!, not sure about perf in the long run -
Nevoic1996y@Phlisg thanks for the clarification, but my point was also centered around the implicit type coercion not just that operation. When I'm forced to write JS (at work), I do use === for the reasons you specified.
But thanks for taking the time! -
Nevoic1996y@D--M because you can change my mind with evidence. My mind is made up because the evidence points clearly towards JS being primitive and crappy to work with, but if I'm missing something I'd obviously change my opinion.
Related Rants
HEY!
JAVASCRIPT!
I wasted 3 hours on your this. self. null, undefined, + asynch functions, bullshit "features"...
AGAIN...
and your taking 8 seconds to compile and test each wild guess that I make until I finally console.log every single fucking variable in order to make sense of it all
so, as usual, FUCK YOU
rant
javascript