MasterPtato MasterPtato - 1 year ago 101
Javascript Question

What does obfuscated code mean?

So I was on a site and I was peeking into the source code, and all the JavaScript code was obfuscated(as usual). I don't know what obfuscated code would be normally, but I think its like this:

var1 > 10 / 2, var1 = 0

is the same as

if(var1 > 10 / 2){
var1 = 0;

is this how it is? If not, please tell.

Answer Source

You can see what happen, when you place the code inside of some parenthesis inside of console.log. You need some extra parenthesis, because console.log reads the comma as separator for parameter.

Comma Operator:

The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand.

var var1;
console.log(var1);                      // undefined
console.log((var1 > 10 / 2, var1 = 0)); // 0
console.log(var1);                      // 0

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download