Constant folding is a compiler optimization. The transformation evaluates constant expressions at compile-time to reduce them to the minimum equivalent expression reducing the computing effort in run-time.
// @jscrambler enable constantFolding
The following example shows an expression that evaluate to a constant value:
1 + 2 + '' + 3;
Because this always produce the same output, we can replace the expression with its constant value.
'33';
Browser | Compatible Versions | Tested Versions | Notes |
---|---|---|---|
Chrome | 80+ | 80+ | |
Firefox | 90+ | 90+ | |
Internet Explorer | 8+ | 8+ | |
Microsoft Edge | 116+ | 116+ | |
Safari | 13.1+ | 13.1+ |
Example:
{
"keys": {
"accessKey": "XXXXXX",
"secretKey": "YYYYYY"
},
"applicationId": "ZZZZZZ",
"params": [
{
"name": "constantFolding"
}
]
}