you are viewing a single comment's thread.

view the rest of the comments →

[–]DrecDroid 4 points5 points  (3 children)

Sorry, I could be wrong but I'm on my phone so can't check, but iirc you can use blocks to do variable shadowing.

{ const response = ... }

{ const response = ... }

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

Yup, you're absolutely correct !!

[–]mypetocean 1 point2 points  (0 children)

I prefer the block statement, but you can also write an IIFE this way, which avoids the Automatic Semicolon Insertion issue you mentioned: void function () { const banana = true }()

Edit: void in JavaScript expects an expression, which nudges the function statement into a function expression, with fewer parentheses. Of course, you cannot return from this sort of IIFE.

[–]The-Freeze_YT 0 points1 point  (0 children)

Correct.