Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does javascript super mean?

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces what javascript super refers to, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Javascript Super actually refers to the superset TypeScript of javascript, while TypeScript is a free and open source programming language developed by Microsoft that supports the ES6 standard. It can be compiled into pure JavaScript, and the compiled JavaScript can run on any browser.

This article operating environment: windows7 system, javascript1.8.5 version, DELL G3 computer.

What is javascript Super? What is the superset of javascript?

The superset of javascript is TypeScript. TypeScript is a free and open source programming language developed by Microsoft that supports the ES 6 standard; its design goal is to develop large applications that can be compiled into pure JavaScript and the compiled JavaScript can run on any browser.

Introduction to TypeScript:

1. TypeScript is a superset of JavaScript and supports the ECMAScript 6 standard.

Superset: if every element in a set S2 is in set S1, and set S1 may contain elements that are not in S2, then set S1 is a superset of S2, which in turn is a subset of S1. S1 is a superset of S2. If there must be elements in S1 that are not found in S2, then S1 is a true superset of S2, and in turn S2 is a true subset of S1.

TypeScript is a free and open source programming language developed by Microsoft.

3. The design goal of TypeScript is to develop large-scale applications, which can be compiled into pure JavaScript, and the compiled JavaScript can run on any browser.

TypeScript operation:

We can use the tsc command to execute the code related to TypeScript

Usually we use .ts as the extension of the TypeScript code file

Then execute the following command to convert TypeScript to JavaScript code:

Tsc test.ts

At this point, a test.js file is generated in the current directory (the same directory as test.ts).

Use the node command to execute the test.js file

$node test.js

The TypeScript variable declares:

Naming rules for TypeScript variables:

Variable names can contain numbers and letters.

You cannot contain other special characters, including spaces, except the underscore _ and the dollar $sign.

Variable name cannot start with a number

Syntax: var [variable name]: [type] = value

Var [data]: [string] = 'hello world'

Note:

When you declare a variable, no value defaults to the value: undefined

The type of a declared variable is arbitrary when it is given a value and a variable name

When declaring a variable with no value and type, its type is arbitrary, and the value is undefined

An error will be reported if the given value does not match the type.

Basic type:

1. Any type of any: variables declared as any can be assigned values of any type.

2. Numeric type number: double precision 64-bit floating point value. It can be used to represent integers and fractions. A series of characters that use single quotation marks (') or double quotation marks (") to indicate the string type. Backquotes (`) define multiline text and embedded expressions.

Let data: number = 6

3. String type string: a series of characters that use single quotation marks (') or double quotation marks (") to indicate the string type. Backquotes (`) define multiline text and embedded expressions.

Let name: string = "ipad"; let years: number = 5 years words: string = `This year marks the anniversary of ${years + 1}.

4. Boolean type boolean: represents logical values: true and false.

Let flag: boolean = true

5. Enumerated enum: enumerated types are used to define numeric collections.

Enum Color {Red, Green, Blue}; let c: Color = Color.Blue;console.log (c); / / output 2

6. Void void: used to identify the type of value returned by the method, indicating that the method does not return a value.

Function hello (): void {alert ("Hello Runoob");}

7. Null null: indicates that the object value is missing.

8. Undefined undefined: used to initialize the variable to an undefined value

9. Never never:never is a subtype of other types, including null and undefined, and represents values that never appear.

Variable scope:

TypeScript has the following scopes:

The global scope − global variable is defined outside the program structure and can be used anywhere in your code.

Class scope − this variable can also be called a field. Class variables are declared in a class, but outside the methods of the class. This variable can be accessed through an object of the class. Class variables can also be static, and static variables can be accessed directly through the class name.

Local scope − local variables, local variables can only be used in a block of code that declares it (such as a method).

TypeScript output:

The output of TypeScript uses the same as JavaScript: console.log ()

Var [ename]: [string] = 'Xiao Ming'; var [age]: [number] = 10 position console.log (ename); console.log (age); Thank you for reading this article carefully. I hope the article "what javascript Super refers to" shared by the editor is helpful to you. At the same time, I also hope you can support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report