x = "-";
console.log("5" + x + "" + "2");
淡淡烟草味2017-05-24 11:39:05
var x = '-'
console.log(new Function('return ' + "5" + x + "" + "2")())
PHP中文网2017-05-24 11:39:05
x = '-'; eval(Number(5) + x + '' + Number(4))
Try this
x = '-'; eval('5' + x + '' + '4')
This is also possible
怪我咯2017-05-24 11:39:05
Complain about where this demand comes from and try to avoid this kind of strange demand
Upstairs is a practice
I provide another one here'1+1'.match(/([0-9]+)(-|+)([0-9]+)
The specific idea is to use regular expressions to match numbers and operators, and then use switch to match the operators to return different results
In addition, if the questioner is studying, I still don’t recommend this weird approach. No one will like this way of writing