Constant Folding

Potency Low
Resilience High
Cost None
Tags: optimization, constant, folding, minification, compiler


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.

Code Annotation Example

// @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.


API Parameters


  "keys": {
    "accessKey": "XXXXXX",
    "secretKey": "YYYYYY"
  "applicationId": "ZZZZZZ",
  "params": [
      "name": "constantFolding"