javascript - How to use the character "+" as a real plus sign
过去多啦不再A梦
过去多啦不再A梦 2017-05-24 11:37:05
0
3
627
x = "-";
console.log("5" + x + "" + "2");
过去多啦不再A梦
过去多啦不再A梦

reply all(3)
淡淡烟草味
var x = '-'
console.log(new Function('return ' + "5" + x + "" + "2")())
Ty80

x = '-'; eval(Number(5) + x + '' + Number(4))

Try this

x = '-'; eval('5' + x + '' + '4')

This is also possible

刘奇

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template