Skip to content

Instantly share code, notes, and snippets.

@theClarkSell
Created August 5, 2011 21:55
Show Gist options
  • Save theClarkSell/1128618 to your computer and use it in GitHub Desktop.
Save theClarkSell/1128618 to your computer and use it in GitHub Desktop.
Using JavaScript’s Strict Variant
<script>
var something = "something else";
"use strict"; // wasn't first statement
foo = "foo"; // will not fail
(function() {
"use strict";
bar = "bar"; // will fail
})();
</script>
<script>
//not so strict
undefined = “foo”; // will NOT fail
(function() {
"use strict";
undefined = “foo”; // will fail
})();
</script>
//let's do bad things - start
undefined = "bad script";
//Good Script - Start
"use strict";
var foo = "bar";
//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