We will be at OWASP APPSEC EUROPE 2017 - Belfast! Let’s talk!MORE INFO

Help Center

Get to know more about our API, Code Annotations and Code Transformations

Variable Grouping

Potency
1 / 3
Resilience
5 / 5
Cost
0 / 5

Tags: variables,grouping,hoisting,obfuscation

Description

Variable Grouping groups your variable declarations into a single variable
statement list
. Additionally, variable hoisting is performed in optimization-time.
Hoisting is JavaScript default behavior of moving declarations to the top of the scope.
This behavior gives you the ability to declare a function or a variable after it
is used.

Examples

The following contrived example does nothing besides declaring a bunch of variables
in different scopes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var a = 1;
var b = 2;
(function () {
var a = 1;
var b = 2;
var c = function () {
var a = 1;
var b = 2;
var c = 3;
}();
var d = 2;
function e() {}
var f = 1;
var g = 2;
}());
var f = 1;
var g = 2;

The resulting code looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var a, b, f, g;
a = 1;
b = 2;
(function () {
var a, b, c, d, f, g;
a = 1;
b = 2;
c = function () {
var a, b, c;
a = 1;
b = 2;
c = 3;
}();
d = 2;
function e() {}
f = 1;
g = 2;
}());
f = 1;
g = 2;

API Parameters

Example:

1
2
3
4
5
6
7
8
9
10
11
12
{
"keys": {
"accessKey": "XXXXXX",
"secretKey": "YYYYYY"
},
"applicationId": "ZZZZZZ",
"params": [
{
"name": "variableGrouping"
}
]
}