117
Ma30h
6y

Thank you JS for challenging our lives

Comments
  • 4
    Hmmmmmm
  • 24
    A good part of those are just logical.. and a very good part are stupid cause you'll never do it :/
  • 3
    Javascript, because fuck commutativity.
  • 5
    Learn JS maybe.
  • 7
    @AlexDeLarge I don't understand the Math.min() and Math.max() ones
  • 5
    @AlexDeLarge That was gangster as always. And well said to boot!

    #5 of course was my favourite point! Haha
  • 3
    @AlexDeLarge I expected that behavior, but I didn't expect min to return positive infinity and max to return negative infinity.
  • 4
    @AlexDeLarge Probably just a shitty part of the standard. Perhaps if we rant about it enough it will be changed in the next ES version
  • 7
    @AlgoRythm Well, it makes sense.
    Imagine min() is min(infinity)
    Now:
    min(1) is min(1, infinity)
    -> returns 1

    Otherwise if
    min(1) is min(1, -infinity)
    -> returns -infinity 😌
  • 1
  • 2
    @AlgoRythm Well, returning undefined would've been more elegant D:
  • 3
  • 5
    Makes sense. If only people learned how js works.
  • 1
    If anyone here would read JS documentation, they'd say ahhaa that's why (and this shit)...
    In any case this looks too bad and too hard to understand. I feel bad about people using this 🙃
  • 1
    I didn't understand 3 n 4

    How is 0.5+0.1==0.6 => true n
    0.1+0.2==0.3 =>false
  • 4
    @AlexDeLarge well shit man!!! Next time someone please announce AlexDeLarge's destruction by saying "the representative from Germany has the floor" or something! Brütal and eloquent as always my dude.
  • 2
    @sain2424 it's just a simple floating point error, the well known 0.1 + 0.2 = 0.300000000004, hell it's not just js that have this, "good" language like python have this too
  • 1
    @sain2424 floating point precision.
    This is not just a JS thing and it's the reason why accountig software is always programed with their own data types and/or structures
  • 0
    @AlgoRythm ES is just syntactic sugar, it doesn't change the way JS behaves
  • 0
    But seriously people should just learn how to native JS... Don't call yourself a JS dev if you've never touched a prototype or don't understand how basic comparators work 😅
  • 1
    @frickerg I thought ES was the JavaScript standard...?
  • 0
    @AlgoRythm JavaScript is an implementation of the ES standard, so I guess that would be correct.

    I haven't been following ES before 2016, but to my knowledge every new version of ES did not change the way JavaScript works, hence my comment.

    Taken from the MDN web docs:
    "JavaScript classes, introduced in ECMAScript 2015, are primarily syntactical sugar over JavaScript's existing prototype-based inheritance. The class syntax does not introduce a new object-oriented inheritance model to JavaScript."

    This is just one of many examples on how ES improves the way JS can be written (and read), but the underlying semantic of the language stays the same.

    Comparing it to my second language Java, many new versions include new libraries which extend and improve the language, JS doesn't do that.

    If my statement is wrong stand corrected, but I've never seen an ES code-snippet which cannot be written into pure native JavaScript.
  • 1
    @frickerg Ok, your example, Java. New versions change the language (Like introducing lambdas? ES introduced "arrow functions" for JS) and introduce new functionality (Uint8Array was introduced by ES, that cannot be done in pure JS)

    As far as I understand, ES IS the JavaScript standard, in just this rant, we determined that ES outlined how the Math library works. Sure, JavaScript had a Math library before ES, but the old vanilla JavaScript standard is no longer followed in favor of ES by all major vendors (In fact, it is appropriate to say that the old JS standard evolved INTO ES)
  • 1
    @frickerg You're treating ES like it's a library, such as jQuery. It isn't. ES is the JavaScript standard, not syntactical sugar (the class keyword is used to shorten the prototyping process. That bit of the standard IS just syntactical sugar. However, ES also outlines the prototyping process, so it's syntactical sugar for itself.) I don't mean this in a rude tone, but I fear you have a fundamental misunderstanding of ES.
  • 0
    @AlgoRythm it's almost 2 AM over here so I might got some things wrong or didn't write them the way I intended to I'll let you know tomorrow 😂 However I know that ES is not a library, hence the comparison with Java which extends upon many libraries out-of-the-box.

    I doubt that I misunderstand ES, since I've worked with it over two years, but we can settle after a good night's sleep mate 🤗
  • 1
    @AlgoRythm alright I read it all over again and your definition is more correct than mine. As far as I know, the ES standard and JS appeared around the same time and ES is in fact the standard on how a scripting language should look like.

    The information you've provided is very interesting and helpful, thanks for that.
  • 2
    God I hate JavaScript so much. Like just look at this http://cpp.sh/2k4ha !!
    Oh wait.

    Also more than half of these can be considered shooting yourself in the foot.
    0 is because of IEEE754
    1, 2, 3 isn't exclusive to JS
    4, 5 should just be considered silly since those methods finds the maximum and minimum of the values passed.
    6, 7, 8 Here we have cases of doing stuff that makes no sense
    9, 10 1 + 1 + 1 gives 3 while 1 - 1 gives 0? Mind === blown. Also http://cpp.sh/42gtp
    11, 12 and here we have the case for ===. It's known as type coercion and isn't exclusive to JS
    13 This isn't a challenge to anyone's life. It seems silly, sure, but it really isn't
    14, 15 yet no one considers the fact that they're trying to do maths on strings. That should be a warning flag
    16 empty array to string is empty string, which is falsy. 0 is falsy too, and == checks for falsy
  • 0
    There is someone to teach me Js ? 😁
Add Comment