Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is using with in javascript bad practise?

I'm thinking that stuff like with(Math){document.body.innerHTML= PI} wouldn't exactly be good practise.

like image 669
DarkLightA Avatar asked Jan 20 '23 20:01

DarkLightA


1 Answers

I would call it bad practice, considering how it affects the scope chain.

Take a look at this article from Douglas Crockford: "with Statement Considered Harmful"

like image 96
Matt Avatar answered Jan 30 '23 19:01

Matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!