爲什麼此代碼不起作用? 我有以下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