I misspelled "use strict" to "use stricr"

40 Views Asked by At

this code gives error which makes perfectly sense

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script>
usestricr
</script>
</body>
</html>

but this doesn't why

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<script>
"usestricr"
</script>
</body>
</html>

please help i'am noob in this

1

There are 1 best solutions below

1
Quentin On

So that triggering strict mode in JS engines that support it wouldn’t cause errors to be thrown in older engines, the code to trigger it is just a string.

Putting a different string there is still just a string which is still syntactically valid even if semantically nonsense.