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
-
IcyTv1197yIt's cause there are people whodon't understand Js concepts and can't get their head around JavaScript so they hate on it
-
@IcyTv Well, it does have some... Ahem, unique concepts though.
1 == "1" vs 1 === "1" is weird until you understand why it is necessary here. -
@inaba Sorry, I didn't know other languages are doing that - or at least, I never needed another language to do that. I can understand it in JS (Form Input might come as all sorts of things depending on the browser), but I could not see a use in any other context than that...
-
@ilPinguino quite many weakly typed languages do that, '1' == 1 is expected, less expected is things like [+!+[]]+[+[]] === 10
-
@ItsNotMyFault I don't mean 1 == "1", I mean the === operator - the "be strict this one comparison" thing is something I never seen in another language.
As for your [+!+[]]+[+[]] example...
Why would anyone actually DO that??? -
@thremedy I did some PHP a while ago, but I don't really remember doing that... Looks like I was not in deep enough...?
-
IcyTv1197y@ilPinguino cause we need a way to compare integers while making sure they're actually integers...
Also java? == sometimes compares memory addresses while sometimes comparing the value. The equivalent to === would be . equals()... -
@ilPinguino also in Elixir and many of the newer dyanmically typed langs; it makes sense to have it too since that corresponds to the triple bar equals sign in math
-
@woodworks Elixir is one of the many languages I never had contact with. I moved from Basic via some C-likes (C++, C#.net) over to PHP, Perl, Python and later, Ruby on Rails... I'd not consider myself more than "dabbling" in anything but RoR, Python and PHP. Also, I always was a serverside/backend guy - some JS, very litte CSS.
I only recently(2ish years ago) got back into C++ because I tinker with IoT devices. -
@senzory I would say the opposite, people who can't code should not use flexible, forgiving languages like javascript, it is far too easy to create horrible things with it.
-
@ilPinguino I've been in similar stacks as well :) but I've got a ton of free time on my hands so I'm always looking to get proficient in new langs; I personally absolutely hate Haskell and most functional languages but Elixir doesn't shove it down your throat and is pretty elegant. IMO definitely the best functional lang
-
rim011227yJS concepts... Undefined, NaN or null ? Can someone explain when which one will be returned ?
-
inaba46257y@rim01 When you try to access a value that doesn't exist, you will get undefined. So when you declare a variable without a value and try to get the value of it, it's not defined.
When you need to know that something is an empty object, like if you have optional parameters, or you get something from a database that is null, or stuff like that.
And NaN is what you get when your dumb ass tries to do maths on things that aren't numbers (or aren't silently converted to numbers).
1/"a"
1/"1a"
1/{}
1/[1,2]
and so on will give you NaN because, they're not numbers. These however, will not
1/"1"
1/[]
1/[1]
because they're silently converted. Then there's also the good old string concatenation:
1 + {} == '1[object Object]'
Will give you true. Now all of these are quite easily fixed by following one simple rule:
Maths is for numbers.
Related Rants
why so much hate towards javascript? :-D
joke/meme
js
javascript