Articles → JavaScript → Strict Mode In Javascript
Strict Mode In Javascript
What Is Strict Mode?
Syntax
If Undeclared Variable Is Used In Strict Mode
<html><head><title>Strict mode Demo</title><script>
"use strict";
try {
pi = 3.14;
alert(pi);
} catch (e) {
alert(e);
}
</script></head><body></body></html>
If Variable Are Declared In Strict Mode
<html><head><title>Strict mode Demo</title><script>
"use strict";
try {
var pi = 3.14;
alert(pi);
} catch (e) {
alert(e);
}
</script></head><body></body></html>