Hey Folks, Hope you're all doing great.
Today, I wanted to talk about some weird things that are really really weird about Javascript language and...
For further actions, you may consider blocking this person and/or reporting abuse
Your increment operator example makes no sense - it is completely meaningless to use it on anything other than a variable... what are you going to increment if trying to apply it to a fixed value?
The
0.2 + 0.1
problem is present in an awful lot of languages. It's a problem with floating point numbers, not JavaScript.Also not sure why you think the comma operator is 'weird' - that's just how it works. What would you expect it to do?
I heavily aggree with this reaction.
Regarding the 0.2 + 0.1. Jon is right. You should search this up if you want to have a detailed explanation of WHY it is not 0.3. (I find this quite fascinating of why it is happening)
But anyway, I genuinely think that every language is weird. But weird in its own way. We just have to put in the time and effort to learn and time will eventually come where you find out whether you like the language or not.
I agree that this is weird behavior, but I think (with the exception of the comma operator) this is pretty standard if you come from any other language.
Floating point operations lack base 10 accuracy no matter the language, increment has traditionally been a side efect-full operation on a variable. The only language I can think of that treats extra commas as empty (the 'expected' behavior) is Verilog (arguably not a coding language). And yeah I'll concede the comma operator thing is weird, I would expect it to create a list-like object or a syntax error.
That being said I think this is a fun look at why languages are weird in general, and it's certainly something we all had to learn at one point. Thanks for sharing!
Not all, but a lot.
Also, Python does have
Decimal
class.I don't think this one work in any programming language. What would a predefined value be mutable?
But of course this works.
another one that thinks js is weird and doesn't even bother to learn BASIC programming rules. how do you imagine incrementing to a boolean? how would that work? learn about floating point maths, seems like your knowledge is lacking, then write an article
Plenty of people learn by writing. And putting these articles out can help with that. Sure maybe there should be some kind of disclaimer about still being new, but I don't think it's appropriate to gate people off based on knowledge, as writing and blogging about these often abstract processes in plain speak is an important step in the process of learning for some.
this is plain misinformation, and beginner programmers could really think that javascript is bad because of those nonexistent issues
Incrementing to a boolean isn't a normal thing to do in the first place; but the exact result depends on Boolean implementation.
Otherwise, a lot of things depend on the parser, e.g. what browser are you using; if the standard isn't written.
Thanks everyone for your time commenting on my first post and indicating what exactly is wrong. I appreciate your ideas and make suitable changes.
What's your point exactly, Umang. Every language has their limitations but the things you wrote here are not limitations.