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

How to use JavaScript syntax

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of how to use JavaScript grammar, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this article on how to use JavaScript grammar. Let's take a look at it.

JavaScript is a scripting language, it is a lightweight but powerful programming language.

Each line of code is an instruction and requires a Terminator

JavaScript syntax is strictly case-sensitive!

2.1 literal quantity

In programming languages, a general fixed value is called a literal quantity

The literal quantity of a Number can be an integer or a decimal, or a scientific count (e)

String (String) literals can be in single or double quotation marks

The literal quantity of the expression is used to calculate

Array (Array) literally defines an array

Object (Object) literally defines an object

Function (Function) literally defines a function

/ / numeric literal quantity

3.14

/ / string literals

"John Doe"

/ / literal quantity of expression

1 + 2

/ / Array literals

["eat", "sleep", "code"]

/ / literal amount of object

{"name": "Zhang San", "age": "18"}

/ / function digital face value

Function fun () {...}

2.2 variables

In programming languages, variables are used to store data values, JavaScript uses the keyword var to define variables, and equals signs to assign values to variables

Var a = 1

Var b = 2

Variables can be accessed through variable names. In imperative languages, variables are usually variable. The literal quantity is a constant value.

Note: a variable is a name. The literal quantity is a value

2.3 operator

JavaScript uses the arithmetic operator (+-* /) to calculate the value

Document.getElementById ("demo") [xss_clean] = (7 + 8) * 10

JavaScript uses the assignment operator (=) to assign values to variables

Var a,b

/ / variable assignment

A = 1

B = "JS"

2.4 keyword

The JavaScript keyword identifies the action to be performed. Like any other programming language, JavaScript reserves some keywords for its own use.

These keywords are not used in the current language version, but will be used in future JavaScript extensions:

Let 、 new 、 case 、 class 、 if 、 else.... Keywords such as var cannot be declared as variables!

2.5 comments

Single-line comment

One-line comments begin with / /.

Any text between / / and the end of the line will be ignored by JavaScript (will not be executed)

/ / I am the comment content and will not be displayed.

You can also release the note to the end of the code:

Var x declare 5; / / declare x and assign 5 to it

Var yearly xroom2; / / declare y and assign xroom2 to it

Multiline comment

Multiline comments begin with / * and end with * /.

Any text between / * and * / will be ignored by JavaScript

/ *

This is a multiline comment.

All content will not be parsed and executed.

, /

This is the end of the article on "how to use JavaScript Grammar". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to use JavaScript grammar". If you want to learn more, you are welcome to follow the industry information channel.

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