FMUSER Wirless Transmit Video And Audio More Easier !
es.fmuser.org
it.fmuser.org
fr.fmuser.org
de.fmuser.org
af.fmuser.org ->Afrikaans
sq.fmuser.org ->Albanian
ar.fmuser.org ->Arabic
hy.fmuser.org ->Armenian
az.fmuser.org ->Azerbaijani
eu.fmuser.org ->Basque
be.fmuser.org ->Belarusian
bg.fmuser.org ->Bulgarian
ca.fmuser.org ->Catalan
zh-CN.fmuser.org ->Chinese (Simplified)
zh-TW.fmuser.org ->Chinese (Traditional)
hr.fmuser.org ->Croatian
cs.fmuser.org ->Czech
da.fmuser.org ->Danish
nl.fmuser.org ->Dutch
et.fmuser.org ->Estonian
tl.fmuser.org ->Filipino
fi.fmuser.org ->Finnish
fr.fmuser.org ->French
gl.fmuser.org ->Galician
ka.fmuser.org ->Georgian
de.fmuser.org ->German
el.fmuser.org ->Greek
ht.fmuser.org ->Haitian Creole
iw.fmuser.org ->Hebrew
hi.fmuser.org ->Hindi
hu.fmuser.org ->Hungarian
is.fmuser.org ->Icelandic
id.fmuser.org ->Indonesian
ga.fmuser.org ->Irish
it.fmuser.org ->Italian
ja.fmuser.org ->Japanese
ko.fmuser.org ->Korean
lv.fmuser.org ->Latvian
lt.fmuser.org ->Lithuanian
mk.fmuser.org ->Macedonian
ms.fmuser.org ->Malay
mt.fmuser.org ->Maltese
no.fmuser.org ->Norwegian
fa.fmuser.org ->Persian
pl.fmuser.org ->Polish
pt.fmuser.org ->Portuguese
ro.fmuser.org ->Romanian
ru.fmuser.org ->Russian
sr.fmuser.org ->Serbian
sk.fmuser.org ->Slovak
sl.fmuser.org ->Slovenian
es.fmuser.org ->Spanish
sw.fmuser.org ->Swahili
sv.fmuser.org ->Swedish
th.fmuser.org ->Thai
tr.fmuser.org ->Turkish
uk.fmuser.org ->Ukrainian
ur.fmuser.org ->Urdu
vi.fmuser.org ->Vietnamese
cy.fmuser.org ->Welsh
yi.fmuser.org ->Yiddish
1. What is TS
TypeScript is a superset of JavaScript. It mainly provides a type system and support for ES6. It is developed by Microsoft and the code is open source on GitHub. It can be compiled into pure JavaScript. The compiled JavaScript can run on any browser. The TypeScript compilation tool can run on any server and any system. TypeScript is open source.
Its first version was released in October 2012. After many updates, it has now become a force that cannot be ignored in the front-end community. It is not only widely used within Microsoft, but Angular2 and Vue3 also use TypeScript for development Language.
2. TS advantages and disadvantages
advantage:
(1) TypeScript is a superset of JavaScript, .js files can be directly renamed to .ts
(2) Even if there is no explicit type definition, type inferences can be made automatically
(3) Almost all types from simple to complex can be defined
(4) Even if TypeScript compiles errors, JavaScript files can be generated
(5) Compatible with third-party libraries, even if the third-party library is not written in TypeScript, you can write a separate type file for TypeScript to read
(6) The type system increases the readability and maintainability of the code
(7) Have an active community and support ES6 specifications
insufficient:
(1) There is a certain learning cost for students who have not been exposed to static languages, and they need to understand the concepts of Interfaces, Generics, Classes, Enums, etc.
(2) Some development costs may increase in the short term. After all, more definitions of types must be written. However, for a project that requires long-term maintenance, TypeScript can reduce its maintenance costs
(3) Integration into the build process requires some work
(4) It may not be perfect in combination with some libraries
3. Installation and use
The installation method of TypeScript command line tool is as follows:
npm install -g typescript
The above command will install the tsc command in the global environment. After the installation is complete, we can execute the tsc command anywhere.
Compile a TypeScript file: tsc hello.ts
At this time, a compiled file hello.js will be generated. TypeScript will only perform static checks. If errors are found, errors will be reported during compilation (js files will still be generated).
4. Basic
There are two types of JavaScript: primitive data types and object types.
The primitive data types include: Boolean, numeric, string, null, undefined, and the new type Symbol in ES6.
Boolean value:
Use boolean to define the Boolean value type: let isDone: boolean = false;
Note: The object created by the Boolean constructor is not a Boolean value: it is a Boolean object:
let createdByNewBoolean: boolean = new Boolean(1);
// index.ts(1,5): error TS2322: Type 'Boolean' is not assignable to type 'boolean'.
let createdByNewBoolean: Boolean = new Boolean(1); //No error
Calling Boolean directly can also return a boolean type:
let createdByBoolean: boolean = Boolean(1); //No error
In TypeScript, boolean is the basic type in JavaScript, and Boolean is the constructor in JavaScript. Other basic types (except null and undefined) are the same.
5.Value:
Use number to define numeric types
Note: The hexadecimal notation of ES6 will be compiled into decimal by TS, and non-ES6 hexadecimal will be compiled according to the original hexadecimal.
let decLiteral: number = 6;
let hexLiteral: number = 0xf00d;
let binaryLiteral: number = 0b1010; // Binary representation in ES6
let octalLiteral: number = 0o744; // Octal notation in ES6
let notANumber: number = NaN;
let infinityNumber: number = Infinity;
After compilation:
var decLiteral = 6;
var hexLiteral = 0xf00d;
var binaryLiteral = 10; // Binary representation in ES6
var octalLiteral = 484; // Octal notation in ES6
var notANumber = NaN;
var infinityNumber = Infinity;
6.String:
Use string to define the string type:
let myName: string ='tan';
After compilation: let myName = "tan";
7.Null value:
JS has no concept of Void. In TS, void can be used to represent a function without any return value:
function alertName(): void {
alert('My name is tan');
}
A variable of type void is useless, because you can only assign it to undefined and null: let unusable: void = undefined;
8.Null and Undefined:
In TS, you can use null and undefined to define these two primitive data types:
let u: undefined = undefined;
let n: null = null;
Variables of type undefined can only be assigned a value of undefined, and variables of type null can only be assigned a value of null.
But undefined and null are subtypes of all types. In other words, variables of type undefined can be assigned to variables of type number:
let num: number = undefined;
Note: Variables of type void cannot be assigned to variables of type number.
9.Any value:
Any value (Any) is used to indicate that it is allowed to be assigned to any type, so it can be assigned to values of different types:
let myFavoriteNumber: any ='seven';
myFavoriteNumber = 7;
Access to any property on any value is allowed, and it is also allowed to call any method.
After declaring a variable as an arbitrary value, any operation on it will return any type of content.
Moreover, if the variable is not specified when its type is declared, it will be recognized as an arbitrary value type:
let something;
something ='seven';
something = 7;
与此原文有关的更多信息要查看其他翻译信息,您必须输入相应原文
|
Enter email to get a surprise
es.fmuser.org
it.fmuser.org
fr.fmuser.org
de.fmuser.org
af.fmuser.org ->Afrikaans
sq.fmuser.org ->Albanian
ar.fmuser.org ->Arabic
hy.fmuser.org ->Armenian
az.fmuser.org ->Azerbaijani
eu.fmuser.org ->Basque
be.fmuser.org ->Belarusian
bg.fmuser.org ->Bulgarian
ca.fmuser.org ->Catalan
zh-CN.fmuser.org ->Chinese (Simplified)
zh-TW.fmuser.org ->Chinese (Traditional)
hr.fmuser.org ->Croatian
cs.fmuser.org ->Czech
da.fmuser.org ->Danish
nl.fmuser.org ->Dutch
et.fmuser.org ->Estonian
tl.fmuser.org ->Filipino
fi.fmuser.org ->Finnish
fr.fmuser.org ->French
gl.fmuser.org ->Galician
ka.fmuser.org ->Georgian
de.fmuser.org ->German
el.fmuser.org ->Greek
ht.fmuser.org ->Haitian Creole
iw.fmuser.org ->Hebrew
hi.fmuser.org ->Hindi
hu.fmuser.org ->Hungarian
is.fmuser.org ->Icelandic
id.fmuser.org ->Indonesian
ga.fmuser.org ->Irish
it.fmuser.org ->Italian
ja.fmuser.org ->Japanese
ko.fmuser.org ->Korean
lv.fmuser.org ->Latvian
lt.fmuser.org ->Lithuanian
mk.fmuser.org ->Macedonian
ms.fmuser.org ->Malay
mt.fmuser.org ->Maltese
no.fmuser.org ->Norwegian
fa.fmuser.org ->Persian
pl.fmuser.org ->Polish
pt.fmuser.org ->Portuguese
ro.fmuser.org ->Romanian
ru.fmuser.org ->Russian
sr.fmuser.org ->Serbian
sk.fmuser.org ->Slovak
sl.fmuser.org ->Slovenian
es.fmuser.org ->Spanish
sw.fmuser.org ->Swahili
sv.fmuser.org ->Swedish
th.fmuser.org ->Thai
tr.fmuser.org ->Turkish
uk.fmuser.org ->Ukrainian
ur.fmuser.org ->Urdu
vi.fmuser.org ->Vietnamese
cy.fmuser.org ->Welsh
yi.fmuser.org ->Yiddish
FMUSER Wirless Transmit Video And Audio More Easier !
Contact
Address:
No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620
Categories
Newsletter