// num1和num2和symbol都是变量这里为了比较给他们三个赋了三个值
let num1 = '50'
let num2 = '80'
let symbol = '=='
if (eval(`num1 ${symbol} num2`) == true) {
console.log('比较成功')
} else {
console.log('比较失败')
}
使用js中的eval方法比较三个变量
于 2023-07-04 11:13:43 首次发布
// num1和num2和symbol都是变量这里为了比较给他们三个赋了三个值
let num1 = '50'
let num2 = '80'
let symbol = '=='
if (eval(`num1 ${symbol} num2`) == true) {
console.log('比较成功')
} else {
console.log('比较失败')
}