Skip to content
DevMeme
6830 of 7435
JavaScript Quiz: When Reserved Words Meet Variable Names
Languages Post #7489, on Nov 27, 2025 in TG

JavaScript Quiz: When Reserved Words Meet Variable Names

Description

A multiple-choice quiz question (number 13) on a clean light gray background asking 'Which of the following JavaScript statements is syntactically correct?' with four options displayed in monospace font: a) let let = 42; b) let var = 42; c) var let = 42; d) var var = 42; Each option is preceded by an unchecked checkbox. The humor lies in the absurdity of using reserved keywords as variable names - in JavaScript, 'let' is only a reserved word in strict mode, so 'var let = 42;' (option c) is syntactically valid in sloppy mode. Meanwhile 'var' is always a reserved word, so options b and d fail. Option a also fails because 'let' cannot be re-declared with 'let' in the same scope. The question exploits JavaScript's notoriously inconsistent handling of reserved words across strict and non-strict modes

Comments

25
Anonymous ★ Top Pick The correct answer is c) var let = 42; because 'let' is only reserved in strict mode -- proving once again that JavaScript's idea of 'reserved' is more of a gentle suggestion
  1. Anonymous ★ Top Pick

    The correct answer is c) var let = 42; because 'let' is only reserved in strict mode -- proving once again that JavaScript's idea of 'reserved' is more of a gentle suggestion

  2. @ZmEYkA_3310 7mo

    Javascript can suck my nuts

    1. Deleted Account 7mo

      what about c++?

      1. @ZmEYkA_3310 7mo

        Same

  3. @DerKnerd 7mo

    I like those shenanigans, like when people use C or C++ define to change words :D Or like create a German C

  4. @amadare42 7mo

    It makes a lot more sense that might initially seem. JS is a giant hodge-podge of legacy apis and behaviors that keeps user-facing web together. You cannot afford breaking some poor soul's site if they incidentally used "let" as variable name. It was absolute valid syntax before "let" was introduced as a keyword. Therefore this behavior is specifically permitted to maintain backwards-compatibility. It isn't there to use in new code. And if you think about, this is good entry-level interview question to ensure that candidate understands that a large portion of JS is legacy stuff that no-one should use. As well as illustrates their reasoning ability, since it is unlikely that this piece of esoteric knowledge it readily known.

  5. @LeakyRectifiedLinearUnit 7mo

    i hate the fact that a language meant to manipulate HTML is being used to write backend services

    1. @suttbex 7mo

      just saying "backend" feels like an understatement ive seen people train and run models in js

    2. @vgy4sw 7mo

      Goddaym bro. You're totally wrong here.

  6. @suttbex 7mo

    at least python calls to c yknow

    1. dev_meme 7mo

      So you think backend JS doesnt? Gotcha

      1. @purplesyringa 7mo

        the context is model training/inference, not backend, hope this helps

        1. dev_meme 7mo

          You still can call all the same C code from JS that you call from Python 🤷‍♂️

          1. @purplesyringa 7mo

            I mean you can, it just depends on whether frameworks provide usable bindings

            1. @DerKnerd 7mo

              But it is the same with Python isn't it?

              1. @purplesyringa 7mo

                yes, but Python is used in ML much more commonly

                1. @DerKnerd 7mo

                  yeah for sure, but it is still not that different. And there are, surprisingly, many bindings for ml stuff

      2. @suttbex 7mo

        not on a regular basis, if you're doing anything serious in python its a guarantee its using c in the back instead js "people" love to push and cram it anywhere and everywhere no matter what, they'd rather die than using anything else or interfacing to something else

  7. @Vlasoov 7mo

    probably still easier than C++ implicit cast questions

    1. @DerKnerd 7mo

      or understanding a 10k line header file with #define and #if

  8. @ZmEYkA_3310 7mo

    Literally the most iconsistent scoping known to mankind

  9. @ZmEYkA_3310 7mo

    the standards are a fucking joke

  10. @ZmEYkA_3310 7mo

    Unsigned long long for it to be u64

  11. @ZmEYkA_3310 7mo

    Long double is 64+arch bits long

  12. @theodolu 7mo

    https://youtu.be/7fGB-hjc2Gc

Use J and K for navigation