'var' and 'let' in Typescript 1.5

China☆狼群 提交于 2019-12-04 22:45:23
thoughtrepo

The easiest way to find answers to these type of questions to try it out in the TypeScript Playground.

TypeScript renames the variables within the block scope. There's no performance overhead compared to using regular variables defined with var.

This code:

var i = 0;
for (let i = 0; i < 5; i++) {}
i++;

Compiles to:

var i = 0;
for (var i_1 = 0; i_1 < 5; i_1++) { }
i++;

Here is some more information regarding let.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!