• Traister101
    link
    fedilink
    arrow-up
    1
    arrow-down
    2
    ·
    8 hours ago

    JavaScript doesn’t have typed parameters or variables. The function expects a string and does things in the function body which converts the object into a string. JS shares this behavior with all dynamically typed languages and it’s extremely useful in some contexts and extremely frustrating in others. It’s down to what it’s being used for. Dynamic languages make excellent scripting languages, see Python really just being a souped up shell lang

    • Victor@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      6 hours ago

      The function expects a string and does things in the function body which converts the object into a string.

      … These are different words that describe exactly what I’m saying. I’m saying: in the place where there should be a string argument, because the function expects one, there is not a string argument, but a number argument. (Not an object like you keep saying.)

      I know all that stuff about dynamically typed languages. I’m just saying that the function is being used indirectly here.

      • Traister101
        link
        fedilink
        arrow-up
        1
        ·
        6 hours ago

        You cannot have a string argument, arguments and variables in JS don’t have a type. All you have in JS is objects. Actual functions, like full on function foo(){} are still objects, like you can actually store data on the things.