ES6 and Typescript Tutorial - 43 - Type Inference

preview_player
Показать описание

📱 Follow Codevolution

ES6 | ES2015 | Typescript | ES6 Tutorial | ES2015 Tutorial | Typescript Tutorial | ES6 Tutorial for Beginners | ES2015 Tutorial for Beginners | Typescript tutorial for Beginners
Рекомендации по теме
Комментарии
Автор

I agree it's better to use annotations if you want your types to be precise, but I beg to differ on the focus about the n2 assignment being wrong: what if you want to create a string with a dynamic value from elsewhere on it? That's what's going on with n2 and shouldn't be an invalid case.

Asthbendriel
Автор

With type declaration the n2 is again string


var n1:number = 10;
var n2 = n1 + 'Hello';
console.log(n2);

choudharymustansar
Автор

The type of let x =[0, 1, null] console.log(typeof(x)); is object. why?

choudharymustansar