Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is strict mode's activator 'use strict' a string?

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;?

like image 450
Cole Avatar asked Dec 24 '22 08:12

Cole


1 Answers

use strict; would throw an error in JS engines that did not support strict mode.

Using a string is backwards compatible.

like image 200
Quentin Avatar answered Jan 08 '23 22:01

Quentin