Skip to content

batchReplace

String.prototype.batchReplace(needle)

字符串批量替换。

参数说明类型可选值默认值
needle映射对象Object

返回值:String

js
var str1 = 'C = (a + b) * 2';
var str2 = str1.batchReplace({
    a: 10,
    b: 5,
});
console.log(eval(str2));