Reputation: 441
Not to be confused with wanting to know how use strict works, but why is strict mode activated with 'use strict';
or "use strict";
as opposed to an expression like use strict;
?
Upvotes: 5
Views: 70
Reputation: 1969
I think the answer is simple. As we know, ECMAScript a.k.a javascript is not standarized until now. So why string? It's because all browsers agree to use 'use strict'
as more preferable than use strict
. It also to prevent error on older browser which is not support strict mode.
Upvotes: -1
Reputation: 943585
use strict;
would throw an error in JS engines that did not support strict mode.
Using a string is backwards compatible.
Upvotes: 11