1

I have a question, not about the JS code obfuscation ( it's not really the subject), but for understand a JS if else notation.

When we use obfuscation tools on JS code, the generated code contains a statement like this :

(0xA6, 78.) <= 0x204 ? val : otherVal

I know the if Else statement and the reduce version. in this exemple the obfuscate tool use numbers with other hex base ( ok for this )

But the notation :

( value , other value )

Why this and for make what ?

Thanks for your help to understand this.

4

2 回答 2

3

它是一个逗号运算符:

javascript 逗号运算符

Mozilla 逗号运算符

于 2013-03-20T09:43:15.350 回答
1

好吧,逗号分隔的列表只评估最外面的右值,在这种情况下是 number 78。它也可能看起来像

(0xA6, 42, 11, 78.)

它仍然会评估为78(最后的小数点只是可选的)。第二个数字只是数字的八进制版本516。所以实际上这条线是

78 < 516 ? val : otherVal

这是一个用三元运算符编写的非常简单的条件,它也可以写成

if( 78 < 516 ) {
    // assign val somewhere
} else {
    // assign otherVal somewhere
}
于 2013-03-20T09:44:49.997 回答