On Monday, March 25, 2019, ViliusCreator <[email protected]> wrote:
> ```js > > let a = 10 > > a += ‘1’ // ‘101’ > > // or > > a += undefined // NaN > > ``` > > VS this: > > ```js > > let a: number = 10 > > a += ‘1’ // Error, cannot convert type string to type number. > > // or > > a += undefined // Error, number doesn’t have nullable mark. > > ``` > Thought experiment: ```js let a = 10; let b: number = 10; a === b; // true ``` Would an error at runtime or compiletime occur here? ```js a += '1'; // ok b += '1'; // error ``` If it is a runtime error, is it optimal for the engine to keep track of typed variables vs regular for the same value? If not and it is a compiletime error, what happens here? ```js var x = something(); a += x; b += x; // error? ```
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

