Created
August 5, 2011 21:55
-
-
Save theClarkSell/1128618 to your computer and use it in GitHub Desktop.
Using JavaScript’s Strict Variant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var something = "something else"; | |
"use strict"; // wasn't first statement | |
foo = "foo"; // will not fail | |
(function() { | |
"use strict"; | |
bar = "bar"; // will fail | |
})(); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
//not so strict | |
undefined = “foo”; // will NOT fail | |
(function() { | |
"use strict"; | |
undefined = “foo”; // will fail | |
})(); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//let's do bad things - start | |
undefined = "bad script"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Good Script - Start | |
"use strict"; | |
var foo = "bar"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//let's do bad things - start | |
undefined = "bad script"; | |
//Good Script - Start | |
"use strict"; | |
var foo = "bar"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment