home.social

#variablescope — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #variablescope, aggregated by home.social.

  1. Ruby has a peculiarity: when you define a variable in a conditional expression (if / unless / case / ternary if), it becomes visible from then on.
    It's as if it was assigned nil before the conditional expression, and you don't need to explicitly declare it.
    But if you define a variable in a block, it is defined in the local scope and is no longer visible outside the block.

    #Ruby #Condition #ControlExpressions #If #Block #VariableDefenition #VariableScope

  2. new Function() Ignores Local Scope?!

    Function constructor is DANGEROUS! It always runs in GLOBAL scope, ignoring any variables in the enclosing function. Your local 'x' becomes invisible. This scoping behavior will cause HIDDEN bugs!

    #javascript #javascripttricks #functionconstructor #globalscope #variablescope #javascriptweird #javascriptquiz #codingchallenge #javascriptshorts #javascriptwtf #scopequirks #advancedjavascript

    youtube.com/watch?v=LKJ_9YKFSKY

  3. new Function() Ignores Local Scope?!

    Function constructor is DANGEROUS! It always runs in GLOBAL scope, ignoring any variables in the enclosing function. Your local 'x' becomes invisible. This scoping behavior will cause HIDDEN bugs!

    #javascript #javascripttricks #functionconstructor #globalscope #variablescope #javascriptweird #javascriptquiz #codingchallenge #javascriptshorts #javascriptwtf #scopequirks #advancedjavascript

    youtube.com/watch?v=LKJ_9YKFSKY

  4. new Function() Ignores Local Scope?!

    Function constructor is DANGEROUS! It always runs in GLOBAL scope, ignoring any variables in the enclosing function. Your local 'x' becomes invisible. This scoping behavior will cause HIDDEN bugs!

    #javascript #javascripttricks #functionconstructor #globalscope #variablescope #javascriptweird #javascriptquiz #codingchallenge #javascriptshorts #javascriptwtf #scopequirks #advancedjavascript

    youtube.com/watch?v=LKJ_9YKFSKY

  5. new Function() Ignores Local Scope?!

    Function constructor is DANGEROUS! It always runs in GLOBAL scope, ignoring any variables in the enclosing function. Your local 'x' becomes invisible. This scoping behavior will cause HIDDEN bugs!

    #javascript #javascripttricks #functionconstructor #globalscope #variablescope #javascriptweird #javascriptquiz #codingchallenge #javascriptshorts #javascriptwtf #scopequirks #advancedjavascript

    youtube.com/watch?v=LKJ_9YKFSKY

  6. new Function() Ignores Local Scope?!

    Function constructor is DANGEROUS! It always runs in GLOBAL scope, ignoring any variables in the enclosing function. Your local 'x' becomes invisible. This scoping behavior will cause HIDDEN bugs!

    #javascript #javascripttricks #functionconstructor #globalscope #variablescope #javascriptweird #javascriptquiz #codingchallenge #javascriptshorts #javascriptwtf #scopequirks #advancedjavascript

    youtube.com/watch?v=LKJ_9YKFSKY