00:00
00:00
Newgrounds Background Image Theme

FylypFimpossible just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Using the "use strict" (JavaScript)

1,013 Views | 3 Replies
New Topic Respond to this Topic

I've read a lot about the "use strict"; mode that came out not so long ago to JavaScript to optimize code. It makes it easier to make better code.

So, I decided to use the mode in all my JavaScript codes, but in JSHint, it says it have to be defined in every single function. But all I want is to be strict with my whole code. I'm comfused!

Do I have to add "use strict"; to every single function or just at the start of my .js file?

Response to Using the "use strict" (JavaScript) 2012-02-13 22:25:05


At 4 days ago, Rawnern wrote: I've read a lot about the "use strict"; mode that came out not so long ago to JavaScript to optimize code. It makes it easier to make better code.

So, I decided to use the mode in all my JavaScript codes, but in JSHint, it says it have to be defined in every single function. But all I want is to be strict with my whole code. I'm comfused!

Do I have to add "use strict"; to every single function or just at the start of my .js file?

For anyone coming across this in the future (as the OP posted this a few days ago and likely found the answer already): This suggests throwing it at the top of the file to enable it for the whole script.

Response to Using the "use strict" (JavaScript) 2012-02-14 11:15:44


Response to Using the "use strict" (JavaScript) 2012-02-14 14:49:00


At 16 hours ago, Scyllinice wrote: For anyone coming across this in the future (as the OP posted this a few days ago and likely found the answer already): This suggests throwing it at the top of the file to enable it for the whole script.

Thanks for your help! Exactly what I was looking for.

At 3 hours ago, Wolfos wrote: Something like this?
http://www-archive.mozilla.org/js/language/js20-2002-04/core /pragmas.html

Oh, I´ve already red that one. It´s kinda old. This rule came in 2009 etc...