为什么此代码不起作用? 我有以下app.ts var a = 1;
var b = 3;
console.log(`Before a = ${a}, b = ${b}`);
[a, b] = [b, a];
console.log(`After a = ${a}, b = ${b}`);
当我尝试用 node app.ts 运行它,我有下: [a, b] = [b, a];
^
是否有办法将构造函数的解构中的财产公开为公共财产? 假设人类中有许多属性。 而不是 // to create a Person. new Person('')
class Person {
constructor(public name: string) {
}
}
我想用解构传递对象作为构造函数的参数,使性能公众。 //new Person({name: ''})
我用解构宣布一些像这样的变量: const { a, b, c } = require('./something'),
{ e = 'default', f = 'default'} = c;
有没有一种方法,使之成为一条线吗? 我已经试过类似: const { a, b, c = { e = 'default', f = 'default'} } = require('./some
人能做到 import Foo, { bar } from 'foo-with-bar'
然而,类似于可以利用解构的东西,像 let { * as Foo, bar } = getFooBar()
? 假设getFooBar()和foo-with-bar模块返回 { foo: 1, bar: a => console.log(a) }
和import/let后,预计这将打印1: bar
在elisp中,我如何获得正则表达式匹配的解构绑定? 例如, ;; what is the equivalent of this with destructuring?
(with-temp-buffer
(save-excursion (insert "a b"))
(re-search-forward "\\(a\\) \\(b\\)")
(cons (matc