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