小编lam*_*345的帖子

节点的多行 `console.table({a: "aaa\naaa", b: "bbb\nbbb"})`

有没有办法在节点中绘制多行表格?我试过这个:

console.table({a: "aaa\naaa", b: "bbb\nbbb"})
Run Code Online (Sandbox Code Playgroud)

但这只是删除所有换行符:

不带换行符的节点的 console.table 示例数据

javascript command line node.js

2
推荐指数
1
解决办法
1482
查看次数

如何在严格模式下替换`with`语句

此代码运行最佳并且易于理解:

function evalInScope(js, contextAsScope) {
    //# Return the results of the in-line anonymous function we .call with the passed context
    return function() {
        with(this) {
            return eval(js);
        };
    }.call(contextAsScope);
}
evalInScope("a + b", {a: 1, b: 2}); // 3 obviously, but fails in strict mode!
Run Code Online (Sandbox Code Playgroud)

然而,“聪明”的大脑决定删除该with声明,而不进行适当的替换。

问题:如何让它在自动处于严格模式的 ES6 中再次工作?

javascript with-statement strict-mode ecmascript-6

-3
推荐指数
1
解决办法
135
查看次数