3 ms·
That seems weird to me. Does strict mode affect parsing? I thought that parsing completed before execution, so why couldn’t the parser generate the same AST fo
by lakpan 3y ago
That seems weird to me. Does strict mode affect parsing?
I thought that parsing completed before execution, so why couldn’t the parser generate the same AST for these two functions?
(a) => a === undefined ? 1 : a
(a = 1) => a
- jraph 3y ago> Does strict mode affect parsing? Actually, yes. default parameter values could contain things that are allowed in sloppy mode and are syntax errors in strict mode. For instance, a leading zero in numbers without explicitly specifying the base, duplicate property names, the with statement, new reserved words and using delete on a variable name. You need to disallow those in the parameter values in strict mode, but you only know this after encountering the "use strict" marking in the function body if you were not already in strict mode. You can make a parser able to do this, but it is more complex. I guess they decided that this complexity is not worth it.