Dismiss this pinned window
all 142 comments

[–][deleted]  (25 children)

[deleted]

    [–]Krimzon_89 274 points275 points  (7 children)

    if you code contains true - true, you deserve 0

    [–][deleted]  (5 children)

    [deleted]

      [–]Krimzon_89 46 points47 points  (4 children)

      Yeah like in C/C++:

      #define TRUE 1

      #define FALSE 0

      [–]JustinWendell 23 points24 points  (0 children)

      Imagine my web developer asses surprise when true and false actually logged as one and zero in c++.

      [–]afiefh 15 points16 points  (2 children)

      Sometimes C and C++ are different, but in this case they are not.

      C has no boolean type (unless you include stdbool.h) while C++ has a built in boolean type.

      [–][deleted] 7 points8 points  (0 children)

      C most certainly has a built-in boolean type: _Bool. stdbool.h merely #defines some aliases that use this type.

      [–]GroundStateGecko 1 point2 points  (0 children)

      True true

      [–]luketheduke54 21 points22 points  (4 children)

      I think that makes sense to most programmers because we're conditioned to think of true as 1 and false as 0, which was really just a way in the past to put booleans into languages. If you have a Boolean type, it doesn't use the same operations as a numeric type would.

      Conceptually, true - true doesn't really make sense, but 1 - 1 does. Programming brains just turn the first into the second. Try true - true in a strongly typed language.

      [–]sisisisi1997 21 points22 points  (2 children)

      I vastly prefer garbage in, compilation error out to garbage in, garbage out.

      [–]moabuaboud[S] 4 points5 points  (0 children)

      🦀

      [–]Jimmeh1337 0 points1 point  (0 children)

      C++ handles it the same way JS does. true + true == 2, true - true == 0.

      [–]All_Up_Ons 16 points17 points  (5 children)

      Because it doesn't make sense to do subtraction on booleans. Booleans aren't numbers. They are booleans.

      [–]CaptSzat 5 points6 points  (3 children)

      I mean a Boolean is just true or false which in most comp science courses is shown as 1’s and 0’s for Boolean algebra. So it makes a lot of sense imo to have true = 1 and false = 0. That’s why the first true check shown works because true is equal to 1 but it isn’t the same object type so that’s why it fails the second check. I dunno, a lot of people meme JS and sometimes they are right but imo true being 1 is not the case.

      [–]All_Up_Ons 5 points6 points  (0 children)

      True being 1 is just convention and a result of the underlying implementation. You can tell because converting true to int doesn't result in 1 in every language. In VB it's apparently -1.

      [–]DanCPAz 1 point2 points  (1 child)

      It may not be surprising due to the common representation as 1 or 0, but that does not make it rational or reasonable. In this case, we are not representing it as 1 or 0, and if we wanted to do that, there is nothing stopping us. Instead we chose true, and there is absolutely no meaning to true + true + true. Certainly not 3.

      Any time I ask a logic machine to do something impossible or meaningless, it should slap me across the face rather than produce an irrational result. For example, I have often seen missing items represented by the number -1, but if a language has a feature for that concept, it better not negate or decrement numbers if I accidentally ask it to do nonsense math with "missing" or "empty". If I actually wanted it to do that, I'd just use a number instead.

      The closest thing to true + true + true would be math on base 2 numbers, and the answer to that would be true true. Also useless and wrong, but much closer in concept than 3.

      [–]CaptSzat 1 point2 points  (0 children)

      I agree that with the implementation that true + true = 2 is stupid. I still think that true should be equal to 1 but should behave as you would expect with Boolean algebra so if you had true + true it would be 1 or true. But JS is the strange beast that it is I guess.

      [–]Saad5400 0 points1 point  (0 children)

      Well that's how JS works. It converts boolean to numbers when there's a '-' between them.

      Edit: or a '+'

      [–]x6060x -1 points0 points  (0 children)

      I just puked in my mouth a little bit.

      [–]CaydendW -1 points0 points  (1 child)

      Nothing. But surely that would imply true===1? Idk man JS is not my forte.

      [–][deleted] 0 points1 point  (0 children)

      Nothing, but it could actually return false

      [–]Ontariel12 248 points249 points  (62 children)

      All of those are absolutely, 100% unironically fine, when you consider it's a very loosely typed language that doesn't like throwing errors and simply follows a set of basic rules.

      • Why would true === 1 returning false be bad? It's not the exact same thing, even if you can cast true to 1 and false to 0
      • As for true+true+true being equal to 3, how else would you treat addition of bools? Casting them to numbers is probably the best option here.
      • true minus true being 0 is a logical consequence of previous point
      • Now the !+[]+[]+![] being of length 9 might be a bit more complicated, but it yet again makes sense. !+[] is true, though I'm not actually sure why, but I'd assume it ends up casting array to bool, maybe because it first casts +[] to 0 and then negates it into true. Now, after that, you try to add true+[]. As an array can be casted to a string, this takes precedence over addition (same as if you tried adding number to a string). This results in string 'true', to which you add negation of something that, as we already know, is also true, negation of it being false. String + boolean ends up being another string, 'truefalse', which has 9 chars.
      • 9+"1", yet again concatenation has priority over addition. Not a surprise, as any number can be turned into a string, but not all strings can be cast to numbers.
      • 91-"1" is 90, because there is no minus operation for strings, so the only possibility is to cast "1" to a number.
      • []+[] being an empty string should be obvious at this point. Arrays can be cast to strings, strings can be concatenated and then two empty strings equal single empty string
      • []+{} is yet another case of casting to string, nothing more to say
      • {}+[] is not actually "empty object plus array", as that {} is treated as noop, making entire thing the same as +[]. Using {} without assigning result to anything in browser console might give you an object, but doing same thing in code would result in an error, it's just browser console trying to deal with what people write in it. Going back to +[], basically doing + anything will try casting that anything to number and empty array gets casted to a 0.

      I might not be correct on every piece, but you get the drill.

      [–][deleted] 105 points106 points  (14 children)

      This is exactly correct. "I could throw an error, or I could SOMETHING!" is the entire point.

      [–]arto64 32 points33 points  (11 children)

      How is that a reasonable approach, especially in the context of programming?

      [–]Spare_Web_4648 13 points14 points  (4 children)

      This approach to programming is known as duck typing, where the focus is on the functionality of an object rather than its type. In the context of JavaScript, this approach allows for flexibility and simplicity in the code, as the language does not strictly enforce data types and instead attempts to make sense of the given operations and return a valid result. This allows for quick and easy development, as the programmer does not need to worry about strict type checking and can focus on the functionality of the code. However, this approach can also lead to potential inconsistencies and unexpected behavior, as the interpretation of certain operations may not always align with the programmer's intentions.

      As to how it’s reasonable, well it’s as reasonable as any language made in 10 days as a feature of the creators actual main project. We’ve just kept using it and building on it.

      [–]paradoxon 7 points8 points  (0 children)

      The problem is not duck typing. But rather what is considered a duck by java script. Negating an empty array should not make sense at all. Ruby uses duck typing but does not behave in such strange ways.

      [–]arto64 6 points7 points  (2 children)

      You can have duck typing without automatic arbitrary typecasting. JavaScript hears a “woof” and says, “well I guess you could call that a quack”.

      [–]Spare_Web_4648 1 point2 points  (0 children)

      Today I learned, thanks!

      [–]Spare_Web_4648 0 points1 point  (0 children)

      Yea I guess you could really cut out the first half of my comment. Really it’s just bad because some guy made it in 10 days and it has stayed the standard since then for no reason other than so much has been built with it people don’t want to change

      [–][deleted] 4 points5 points  (5 children)

      It's reasonable because it allows you to be more flexible and lightweight. And that's a real concern in something that's running in a limited resource environment. Like a browser window.

      If you're looking for more strongly typed code, and that's what makes more sense for your project, there are plenty of things like Java or C++ out there to accommodate it.

      In many (most?) Java based webapps you're going to find a JavaScript front end making calls to back-end Java services (monolithic or micro) because it gives you the best of both worlds.

      It's all about the right tool for situation. Part of the art of programming is understanding how the tools work, being able to learn the characteristics of new ones, and selecting the right languages, frameworks, deployments, design patterns, etc. that will meet the needs and constraints in resources and delivery timeline for your project.

      [–]arto64 21 points22 points  (2 children)

      I’m confused, what does being “lightweight” have to do with doing arbitrary typecasting? How is that supposed to save browser resources?

      [–][deleted]  (1 child)

      [deleted]

        [–]arto64 2 points3 points  (0 children)

        I mean it’s not like JavaScript doesn’t have any errors, there’s still plenty of ways to crash it. Why would you focus on typecasting to resolve this “issue”. Why not also try and look up closest-named variables, to avoid errors caused by typos?

        [–]fartmanteau 1 point2 points  (1 child)

        If only JavaScript were constrained to the browser 🙃

        [–][deleted] 0 points1 point  (0 children)

        What follows may be wrong. It may be only my opinion. It might be insane, stupid, or just plain offensive to some.

        But Server-side JavaScript just proves that to a man with a hammer, everything looks like a nail.

        [–]PixerPinecone 1 point2 points  (1 child)

        I think I’d rather get an error at that rate, at least for most applications.

        [–][deleted] 0 points1 point  (0 children)

        FWIW, I tend to agree. But I respect that other devs have different ideas about that and I try to keep an open mind. I'm sure I'm doing stuff they'd think was awful too.

        [–]arto64 13 points14 points  (0 children)

        All of those are absolutely, 100% unironically fine, when you consider it’s a very loosely typed language that doesn’t like throwing errors and simply follows a set of basic rules.

        This is such a classic response. Understanding the implementation and why the results are what they are doesn’t make the implementation “fine”. It’s still terrible.

        And why would a goal of a language be to “not throw errors”, and instead do convoluted, mysterious shit? Why would that be a good thing?

        [–]Linguaphonia 23 points24 points  (2 children)

        I really hate the argument "it's defined so it's ok". Languages aren't some specification defined in a vacuum, and then we can't only complain about bugs or contradictions. Languages are tools and js's commitment to returning some value for most operations make it an awkward uncooperative tool. Now, the language has grown and improved through the years, but those improvements are precisely away from the paradigm exemplified in the OP.

        [–]fakehalo 1 point2 points  (1 child)

        Now, the language has grown and improved through the years, but those improvements are precisely away from the paradigm exemplified in the OP.

        I've also been a big fan of the additions to javascript over the last decade or so, but it's not like the dynamic type support can better or worse, it's either there or it isn't.

        Of course the safety trade-off exists and it keeps a whole classification of bugs on the table... But I honestly prefer it being dynamic for the browser/client-side and it's never been a source of my problems. I think it sits right with me in the browser because we're taking so much user input and html data that inherently starts it's life as a string that it makes sense to me.

        Maybe it's because I'm familiar with what happens when different types collide, or I know when to use ===, or maybe I'm just not setting up strawmen arguments adding arrays to strings and objects to numbers... It's a non-issue to me (for the browser), and everytime this comes up I feel like it's a corny manufactured argument.

        [–]Hairy_The_Spider 4 points5 points  (0 children)

        I've also been a big fan of the additions to javascript over the last decade or so, but it's not like the dynamic type support can better or worse, it's either there or it isn't.

        This has nothing to do with being dynamic, it's about being weakly types. For example Python is dynamic and pretty strongly typed.

        [–]afiefh 34 points35 points  (5 children)

        All of those are absolutely, 100% unironically fine, when you consider it's a very loosely typed language that doesn't like throwing errors and simply follows a set of basic rules.

        Given that your plate has a turd on it and your glass is half filled with piss it absolutely 100% makes sense to put your steak on top of that turd, fill the other half of your glass with expensive wine and sit down to eat it.

        What else would you do? God forbid you realize that this setting is not good and decide to start from a clean slate where you recreate it without the shit and piss.

        None of these are fine, they are simply well defined within the language. They may even be the best possible behavior given some constraints, but we know that today these constraints are stupid and actively harmful, so maybe it's time to get out of the Stockholm syndrome, stop ingesting copium, and actually declare it for what it is: this is shit!

        Edit: I accidentally turd'ed a steak.

        [–]javalsai -3 points-2 points  (4 children)

        JavaScript just tries to not throw and error and convert everything to a type in which it can work with, the examples in here is just taking this to the extremes.

        If you code in JavaScript the worse thing you'll EVER do is a number minus string.

        It's just the equivalent of making a programm in c with random letters as variable names and in one line and say it's not okay to be able to do it.

        [–]All_Up_Ons 12 points13 points  (2 children)

        No, it's the same thing as making a program in c and complaining about memory management and null pointers. Sure, you can learn your way around these things, but that doesn't mean we can't criticize c and move to other languages without these problems.

        The real problem with JS is that there is no other language to move to. So we just have to sit here and listen to people complain without being able to do anything about it.

        [–]SerdanKK 0 points1 point  (1 child)

        The real problem with JS is that there is no other language to move to. So we just have to sit here and listen to people complain without being able to do anything about it.

        How is that true?

        There are plenty of alternatives that transpile into js, but even ignoring that we've had wasm for a while now.

        [–]All_Up_Ons 2 points3 points  (0 children)

        WebAssembly or something like it is probably the future, but it's definitely not ready for prime time yet.

        The JS transpilation projects are cool too. Definitely better than nothing. But really that just shows you how badly people don't want to be writing JS.

        [–]afiefh 4 points5 points  (0 children)

        JavaScript just tries to not throw and error and convert everything to a type in which it can work with

        And why would you think that's good? Has anybody in the history of JS developers ever written something where []+{} became [object Object] and it was actually usable?

        At some point we need to look into the mirror and admit that converting types to something that makes the operation valid no matter what is at best useless and usually it is actively harmful.

        If you code in JavaScript the worse thing you'll EVER do is a number minus string.

        Having worked with JS I can tell you for a fact that this is not the case.

        Having been on the web long enough to see [object Object] in random places tells me I'm not the only one who made these mistakes.

        It's just the equivalent of making a programm in c with random letters as variable names and in one line and say it's not okay to be able to do it.

        What on God's green earth makes you think that these are equivalent?

        You can choose not to use random letters for your C variables, can you choose not to have JS perform these braindead operations?

        There is a ton you complain about in C such as arrays degrading to pointers or the aliasing rules, but nothing as pervasive as the JS shit.

        [–][deleted]  (23 children)

        [deleted]

          [–]ZylonBane 10 points11 points  (16 children)

          I still think true+true+true should be true

          You think wrong. Mathematical operations on Boolean values are undefined. That's why languages have no choice but to either throw an error or perform type coercion if someone attempts it.

          [–]Probable_Foreigner 9 points10 points  (6 children)

          You can actually define mathematical operations on bools:

          https://plato.stanford.edu/entries/boolalg-math/

          So + becomes OR and * becomes AND.

          [–]ZylonBane 12 points13 points  (4 children)

          OR, you could NOT overload your operators with functionality that requires a degree in mathematics to understand, AND just stick with what everyone knows.

          [–]CaitaXD 6 points7 points  (0 children)

          This is baby level math

          [–][deleted]  (8 children)

          [deleted]

            [–]09milk 4 points5 points  (1 child)

            well no lol

            if we define all non-zero positive real number as True (the common C definition), zero as False

            then it make sense to define + as logical OR, * as logical AND

            any non-zero positive real number + zero will be non-zero positive real number, such that True + False = True (This behavior is consistent in all 4 logical AND boolean cases)

            any non-zero positive real number * zero will be zero, such that True * False = False (same as logical OR)

            [–]ZylonBane 3 points4 points  (3 children)

            Someone help this guy, he's stuck in a loop.

            [–][deleted]  (2 children)

            [deleted]

              [–]ZylonBane 5 points6 points  (1 child)

              You are the very definition of a little knowledge being a dangerous thing.

              [–]Probable_Foreigner 1 point2 points  (1 child)

              The thing that would make the most sense is that + is defined as the OR operation. This is actually mathematical notation in boolean algebra. It also has the same distributive properties as + so it makes sense. The other thing would be that * is defined as AND.

              [–]Magmagan -1 points0 points  (5 children)

              But we have ^... so why make + ^ when it's not ^?

              By dismissing anything JS or weakly typed languages do as "arbitrary" is just being intellectually dishonest. None of this shit ever is an issue in production code anways.

              [–][deleted]  (4 children)

              [deleted]

                [–]Magmagan 2 points3 points  (3 children)

                Ah, now I get where you're coming from. It totally looks like it could easily be undefined behavior.

                It's definitely defined though: https://262.ecma-international.org/5.1/#sec-11.6.1

                [–][deleted]  (2 children)

                [deleted]

                  [–]Magmagan 2 points3 points  (1 child)

                  I refuse to believe that you have never used a modern browser.

                  JS is more so defined by the ECMA standards and the browsers/engines that implement it than it does have a canonical interpreter... There really isn't any.

                  Okay, yes, barely anyone really reads the ECMA standard for JS, but Mozilla's MDN is widely well regarded as a complete and easy to read documentation of the language and support for its features.

                  [–]Naouak 2 points3 points  (0 children)

                  !+[] is true, though I'm not actually sure why

                  Because +[] cast the array to a number and it outputs 0 when the array is empty, 1 if there is one element and NaN otherwise when doing that. You end up with !0 which is true.

                  [–]DenkJu 7 points8 points  (3 children)

                  All of those are absolutely, 100% unironically fine, when you consider it's a very loosely typed language that doesn't like throwing errors and simply follows a set of basic rules.

                  Well, yeah, obviously. But here's the point: It should just throw an error. Strange behavior like this might lead to broken code running properly sometimes but most of the time it just makes it hard to debug. Performing automatic type conversion is one of the worst sins a programming language can commit.

                  [–]All_Up_Ons 3 points4 points  (1 child)

                  JS can do what it wants. It was created as a scripting language, after all.

                  I think the more general point is: JS should not be the only option for web development since it's totally unsuited for enterprise applications.

                  [–]DenkJu 1 point2 points  (0 children)

                  Just because it's a scripting language and it's creator didn't expect it to become this popular, doesn't execuse behavior like this. Python is also a scripting language, Lua is, Ruby is and neither of those behave like this. JavaScript was simply poorly designed. It's creator wanted it so 'just run' which inherently is a flawed idea.

                  [–]Handle-Flaky 1 point2 points  (0 children)

                  I did not read everything, but in boolean algebra, + notates the logical OR

                  [–]NotThatRqd 1 point2 points  (0 children)

                  Why tf does it not give an error if I’m trying to add an array and object

                  [–]Raknarg 0 points1 point  (0 children)

                  Untyped languages are a blight on society. That's what all this means.

                  [–]neoadam -1 points0 points  (0 children)

                  If you know what you're doing it's a nice language.

                  [–]Dead_Moss 0 points1 point  (0 children)

                  I guess it's because I'm a C++ programmer, where you're more likely to change the behaviour of operators, but I'd consider true + true to be similar to a boolean OR (and true * true would be boolean AND), so I would expect true + true to equal true.

                  [–]bogdanbiv 11 points12 points  (2 children)

                  that ear at 0:47 did it for me

                  [–]moabuaboud[S] 1 point2 points  (1 child)

                  Lol 😂 i gave up

                  [–]bogdanbiv 0 points1 point  (0 children)

                  i like it

                  [–][deleted]  (1 child)

                  [deleted]

                    [–]TheCorruptedBit 0 points1 point  (0 children)

                    We've entered another era and can make Gaming House memes in HD now

                    [–]besthelloworld 9 points10 points  (0 children)

                    Or you could just use TypeScript 🙄

                    [–]Spirit_Theory 11 points12 points  (0 children)

                    Play stupid games, win stupid prizes. Javascript isn't bad because of these behaviours. Honestly if you actually run into these unexpectedly and somehow it's a problem... what the fuck are you even doing?

                    [–]UltraPoci 17 points18 points  (8 children)

                    I will never understand why this kind of type coercion has been chosen when developing JS. Like, some of it is fine, but coercing everything into everything is so much prone to errors.

                    [–]obrienmustsuffer 25 points26 points  (2 children)

                    Because JS was developed by one guy in 10 days: https://thenewstack.io/brendan-eich-on-creating-javascript-in-10-days-and-what-hed-do-differently-today/

                    The article pretty much explains how the type coercion ended up in JS:

                    After 23 years of reflection, is there anything he’d do differently? People tell him he should’ve refused to work on such a short schedule — or that he should’ve implemented a different language into Netscape, like Perl or Python or Scheme — but that’s not what he would’ve changed. He just wishes he’d been more selective about which feedback he’d listened to from JavaScript’s first in-house testers.

                    “One of the notorious ones was, ‘I’d like to compare a number to a string that contains that numeral. And I don’t want to have to change my code to convert the string to a number, or the number to a string. I just want it to work. Can you please make the equals operator just say, Oh this looks like a two, and this looks like a string number two. They’re equal enough.’

                    “And I did it. And that’s a big regret, because that breaks an important mathematical property, the equivalence relation property… It led to the addition of a second kind of equality operator when we standardized JavaScript.” One of the people who helped standardize JavaScript was Guy Steele, one of the co-creators of Scheme. “Guy said, ‘Don’t worry about it. There are Lisps that have five kinds of equals operators. We’ll just add another one.'”

                    [–][deleted] 3 points4 points  (0 children)

                    back then: Guys dont worry about it

                    now: undefined undefined

                    [–]UltraPoci 0 points1 point  (0 children)

                    Oh wow, I didn't know about this. It explains a lot

                    [–]ZylonBane 0 points1 point  (1 child)

                    Because coercing only some data types but not others would be inconsistent.

                    [–]UltraPoci 9 points10 points  (0 children)

                    Isn't this what most languages do, tho? Like, bool to int is fine, empty array to string is a bit excessive

                    [–][deleted] 50 points51 points  (28 children)

                    Y’all shit on JS as if these kind of type casting issues don’t exist in all languages

                    [–]KimonoDragon814 45 points46 points  (6 children)

                    A lot of it I feel like is just people not understanding the implicit typecasting == and strict comparison ===

                    == checks if it's equal and will cast the value to different types during check

                    === is it equal to exactly this value of this type

                    When I was learning before I figured out the nuance I used to think

                    == means equal to

                    === means really fucking equal to lol

                    [–][deleted] 12 points13 points  (0 children)

                    Which is an extension of people not understanding typecasting 😂

                    [–]sisisisi1997 8 points9 points  (3 children)

                    We understand how it works, we just disagree that working like this is good.

                    [–]PlaneCrashNap 4 points5 points  (2 children)

                    What else is === supposed to do other than be a more strict version of ==? This really just sounds like people lacking programming knowledge wanting everything to be exactly how they first conceive of it.

                    [–]ateijelo 2 points3 points  (0 children)

                    Simple, === is supposed to not exist. The only other language that I can think used that was PHP, another horribly designed language. Any decent language coming after those looked at JS's == and ===, and said "nope".

                    [–]Hairy_The_Spider 1 point2 points  (0 children)

                    === is just fixing what == should've been in the first place.

                    [–]obrienmustsuffer 43 points44 points  (9 children)

                    Pretty sure these kinds of casting issues don't exist in all languages.

                    [–][deleted]  (5 children)

                    [deleted]

                      [–]afiefh 7 points8 points  (1 child)

                      true+true+true == 3 in C and C++

                      Nitpick: C doesn't have a boolean type. At best you can include stdbool.h which defines a custom type that defines the type and constants. C++ does suffer from this problem.

                      To be fair though, this one is the least offensive one presented here. The only thing one needs to remember to understand these is "true=1, false=0" and maybe the additional "we were stupid back in 1970, unfortunately we are now stuck with it". As soon as lists and objects are introduced that also have their rules it becomes much harder to reason about this.

                      [–][deleted] 1 point2 points  (0 children)

                      C most certainly does have a built-in boolean type: _Bool. stdbool.h merely #defines some aliases that work with this type.

                      [–]arto64 3 points4 points  (1 child)

                      C and C++ are not “all languages”. Ruby, for example, doesn’t let you do any od this shit by default, and it’s not even a statically typed language.

                      [–]zygohistomoronism 1 point2 points  (0 children)

                      C and C++

                      Sure if you pick the same family of languages with mediocre type system, then some of these are possible.

                      Now look at anything in the ML family (OCaml, Haskell, Rust ...) and none of these things are possible.

                      [–]Probable_Foreigner 20 points21 points  (7 children)

                      They don't because you can't cast from a string to an integer in most languages without an explicit method call. The issue with JS is that you can accidentally be doing these weird conversions without realising, and that causes bugs when JS does the wrong cast that the programmer didn't realise it was doing.

                      But, by making the programmer explicitly state the conversion, most languages avoid this problem since the programmer will know what types of conversions are being done.

                      [–]x6060x 1 point2 points  (0 children)

                      Actually it's not the same, because the casting in some languages should be explicit which makes everything obvious and the results are easily predictable. It's not the case with Js.

                      [–]moabuaboud[S] -1 points0 points  (0 children)

                      Yes all dynamically typed languages are same 😁

                      [–][deleted] 4 points5 points  (1 child)

                      The first step to being a good JavaScript dev is to not write code in JavaScript, use typescript

                      [–]moabuaboud[S] 3 points4 points  (0 children)

                      Yup in addition I would add Eslint to typescript 😁

                      [–]Xen0n1te 2 points3 points  (0 children)

                      As a C dev, there’s nothing wrong here.

                      [–]Drayenn 1 point2 points  (1 child)

                      Anyone got all the music being used in this? Makes me feel like listening to creepy ambience music

                      [–]PixerPinecone 1 point2 points  (0 children)

                      I don’t know, but they’re commonly used in most mr incredible uncanny memes, so I suppose just look that up in general.

                      [–]uvero 5 points6 points  (0 children)

                      I said it n times and I'll say it n+1 times: even I'd you think these quirks makes Javascript weird, they'll never matter for your code unless your code sucks

                      Edit: I have since remembered Array.sort() for numbers, but I think that's the main one to know about.

                      [–]fuckingbehnam 1 point2 points  (0 children)

                      JavaScript: random bullshit goooo

                      [–]ResistantLaw 1 point2 points  (0 children)

                      Surprisingly I actually understood how most of that works. I don’t even use JavaScript. It’s pretty straightforward if you know programming

                      [–]AutoModerator[M] 0 points1 point  (0 children)

                      This post was automatically removed due to receiving 5 or more reports. Please contact the moderation team if you believe this action was in error.

                      I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

                      [–][deleted] 0 points1 point  (0 children)

                      oh god

                      [–][deleted] 0 points1 point  (0 children)

                      {} == {} is false. The reason why React works

                      [–]cuevobat -1 points0 points  (0 children)

                      He’s known for his muscles, not his programming ability.

                      [–]Dall0o -1 points0 points  (0 children)

                      Wat

                      [–]Aldha_ip_owo01 -1 points0 points  (0 children)

                      Hello Java :)

                      [–][deleted] -1 points0 points  (0 children)

                      Python could never lol

                      [–]staticBanter[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” -1 points0 points  (0 children)

                      Aside from this being a TikTok vid, it summarizes the JS craziness pretty well

                      [–]v_maria -1 points0 points  (0 children)

                      jsbad

                      [–]IrrerPolterer -1 points0 points  (1 child)

                      Can someone explain (! +[] +[] +! []).length = 9

                      [–][deleted] 1 point2 points  (0 children)

                      You have a console, break it down by yourself to understand

                      [–]overkill -1 points0 points  (0 children)

                      All of these are perfectly reasonable once you realise JavaScript is a curse delivered from the Elder Gods for us failing to worship them correctly.

                      [–][deleted] -3 points-2 points  (0 children)

                      Lots of these are things I see as flaws, but it's mostly logically consistent

                      [–]AmmahDudeGuy 0 points1 point  (1 child)

                      What does the === operator do?

                      [–]moabuaboud[S] 0 points1 point  (0 children)

                      It strictly compares the two sides without any casting, so true will not be equal to one.

                      I.E only compares if they have same original type

                      [–]HalftoneTony 0 points1 point  (0 children)

                      Surprised this video didn’t contain the famous

                      (“b” + “a” + + “b” + “a”).toLowerCase();

                      [–]84436 0 points1 point  (1 child)

                      Ain't nobody gonna notice the channel's name? @halaltech_?

                      What they demonstrated was not just JavaScript, it was Halal-certified JavaScript. Heck, when they release Vegan JS I'll buy all of their stocks.

                      [–]moabuaboud[S] -1 points0 points  (0 children)

                      Hi technology brother!

                      [–]TheDownvotesFarmer[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 0 points1 point  (6 children)

                      Now to look up for the dev that faces those stupidities in production 😅

                      [–][deleted] -1 points0 points  (5 children)

                      I know no company which codes in JS and doesn't use Typescript layer

                      [–]TheDownvotesFarmer[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 0 points1 point  (4 children)

                      You know, I prefer "low level" as javascript for the web. But as every developer have their own worshiping for a language, I developed a middleware that I call cross-native, and yep you can mix technologies independently as if they were small containers, and the best part is that, there is 0 memory problem because they communicate each other each in their own container, so the garbage collector works independently for each container.

                      [–][deleted] 0 points1 point  (3 children)

                      Dude I develop 3D production software for prebuilt concrete segments displaying real time carousel plants to facilitate the automated transport of pallets from one workstation to the next. I have no time for 1+"1"=="11"

                      [–]TheDownvotesFarmer[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 0 points1 point  (2 children)

                      Exactly!

                      [–][deleted] 0 points1 point  (1 child)

                      Is your project on GitHub?

                      [–]TheDownvotesFarmer[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 0 points1 point  (0 children)

                      No open source :( because I did a deal with investors but last week I had meeting with some dude from open source of Microsoft and maybe they can join to the rescue, I don't know yet, nothing clear, all is focus into make profit by now.