16
0x4139
3y

it makes total sense

Comments
  • 0
    I love those little language idiosyncrasies.

    My favorite is Python dangerous defaults.

    Def func(arg=[]):
    Return Arg.append(1)

    Print(Func())
    Print(Func())

    This will print [1], then [1, 1]
  • 4
    Basically saying you don't understand shit about what you're doing and you're incompetent
  • 1
    It’s just the language signature, like a special move.
  • 2
    it kinda does make sense tho. concatenating as a string makes sense if you're using +, but not if you're using -
    the best interpretation for - is subtraction.
    it's just a matter of understanding that this is not supposed to happen, cause you'd wanna parse that shit before using it. javascript seems to be doing its best at parsing
  • 0
    WAIT

    what

    really?
  • 0
    @darksideofyay yeah, it kinda _does_ make sense.

    which is the scary part.
  • 1
    Just don't add numbers to strings to begin with and you'll get along with JS just fine.

    Also, true / false = Infinity,
    don't @ me
  • 0
    0.1 + 0.2 === 0.3

    false

    :D
  • 4
    @Zysce well, that's just how floating point numbers work. in _every_ language.

    https://floating-point-gui.de/ learn your basics ;)
  • 1
  • 0
    @darksideofyay it makes sense as to *why* it behaves that way.

    it doesn't make sense *that* it behaves that way.
  • 0
    @lungdart what the hell. how?
    isn't the argument scoped out and thus destroyed when the function ends, as it should be? why not?
  • 0
    @localpost "just don't add numbers to strings"

    sure, of cou... oh, wait... JS doesn't have a proper type system. what a surprise.
  • 0
    @Midnight-shcode yeah that's what you would think. But that's not how Python does default arguments, objects, or garbage collection.

    At function declaration time a new list object is created, and the default points to that object if no argument is given.

    Since append modifies the object, and the object is the same every call, it grows the list.

    Cleanup can't happen until the function definition falls out of scope, which is basically never.
  • 0
    @Midnight-shcode but context is everything, specially when the language is trying to fix a mistake the programmer made
  • 0
    @Midnight-shcode That's why you use TypeScript 5head
  • 0
    @localpost oh yes, TS, everything wrong with JS, EXCEPT with all the two good parts of JS that enable fast work in it, plastered over by a shittily done excuse for a type system.

    nothanks. the only thing worse than JS is TS.
Add Comment