当前位置:网站首页>Know typescript

Know typescript

2022-07-24 19:28:00 Michael999

TypeScript yes JavaScript A superset of , Support ECMAScript 6 standard .

TypeScript A free and open source programming language developed by Microsoft .

TypeScript The design goal is to develop large-scale applications , It can be compiled into pure JavaScript, compiled JavaScript Can run on any browser .

JavaScript And TypeScript The difference between

TypeScript yes JavaScript Superset , Expanded JavaScript The grammar of , So the existing JavaScript Code can be associated with TypeScript Working together without any modification ,TypeScript Provide static type checking at compile time through type annotation .

TypeScript Can deal with the existing JavaScript Code , And only for one of them TypeScript Code to compile .

ts And js Relationship
ts And ES5、ES6 Relationship

use TypeScript Write a Hello world Program

TypeScript Classic examples on the official website :

npm install -g typescript

function Greeter(greeting) {
this.greeting = greeting;
}
Greeter.prototype.greet = function() {
return "Hello, " + this.greeting;
}
// Oops, we're passing an object when we want a string. This will print
// "Hello, [object Object]" instead of "Hello, world" without error.
let greeter = new Greeter({message: "world"});
let button = document.createElement('button');
button.textContent = "Say Hello";
button.onclick = function() {
alert(greeter.greet());
};
document.body.appendChild(button);

【 Summary 】:

TS Elegant code , concise . Write it down , Seems to be writing C#, Is there such a feeling , Because it follows C# All from a master --Anders.

原网站

版权声明
本文为[Michael999]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/203/202207211009365273.html