DEV Community

Discussion on: The forgotten `with` statement — and why you shouldn't use it

 
lioness100 profile image
Lioness100

I agree that the "Which is logged?" question isn't particularly useful to determine whether you should us ethe statement or not, since, when creating multiple scopes, you will always run that risk.

const foo = 'bar';
function test() {
  const foo = 'baz';
  console.log(foo); // here it is again
}
Enter fullscreen mode Exit fullscreen mode

However, the much bigger fish I was talking about is when you accidentally reference something you didn't even know existed in the object you use. This problem is not shared with loops since you explicitly write out all variable names, so I don't think your comparison applies.

And what can a linter do? In the example I showed in the post, the linter wouldn't find anything wrong. The only thing linters do is tell you not to use with.