Typescript 3.7 搶先推出Optional Chaining 及 Nullish Coalescing
技術隨筆 + TypeScript + Javascript

Typescript 3.7 搶先推出Optional Chaining 及 Nullish Coalescing

Optional Chaining 及 Nullish Coalescing 可以大大提升 Source Code 可讀性,冇呢兩個 Features 要寫 Equivalent 嘅 Implementation 其實好難。 interface Foo { bar?: Bar } interface Bar { baz(): string } function getFooOrUndefined() : Foo | undefined { return undefined } const foo: Foo | undefined = getFooOrUndefined() const omg = foo?.bar?.baz() ?? 'omg' 阿 Gap 將上述 Typescript Compile 變做 Javascript 比大家作一個參考: "use strict"; var _a, _b; function getFooOrUndefined() { return undefined; } const foo = getFooOrUnd

Javascript V8 嚴重問題!留意返
網絡安全 + IT + Programming + Javascript

Javascript V8 嚴重問題!留意返

暫時測試用番 null === undefined 取代就無事 // Result not consistent : 12291 false, 37709 true for(var i=0; i<50000; ++i) { console.log(typeof null === 'undefined') } // OR for(var i=0; i<50000; ++i) { console.log(typeof null == 'undefined') } // Quick fix for(var i=0; i<50000; ++i) { console.log(null === undefined) } Weak Typing Implicit Conversion.... 不過同大家講番聲用 Weak Typing 嘅 Language 其實要好小心,因為 Implicit convert 好方便,同時都會好易中伏! 留意返! 除咗 Chrome 50、51 Chromium Issue [https://bugs.chromium.org/p/chromium/

Join GLT Community