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 the literal quantity of JavaScript mean

2025-01-16 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 "what is the meaning of JavaScript literal quantity". The editor shows you the operation process through an actual case. The operation method is simple and fast, and it is practical. I hope this article "what is the meaning of JavaScript literal quantity" can help you solve the problem.

JavaScript literal quantity

In programming languages, a general fixed value is called a literal quantity, such as 3.14.

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

3.141001123e5

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

"John Doe" 'John Doe'

The literal amount of the expression is used to calculate:

5 + 65 * 10

Array (Array) literally defines an array:

[40, 100, 1, 5, 25, 10]

Object (Object) literally defines an object:

{firstName: "John", lastName: "Doe", age:50, eyeColor: "blue"}

Function (Function) literally defines a function:

Function myFunction (a, b) {return a * b;} JavaScript variable

In a programming language, variables are used to store data values.

JavaScript uses the keyword var to define variables and uses the equal sign to assign values to variables:

Var x, lengthx = 5length = 6

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

A variable is a name. The literal quantity is a value.

JavaScript operator

JavaScript uses arithmetic operators to calculate values:

(5 + 6) * 10

JavaScript uses the assignment operator to assign values to variables:

X = 5y = 6z = (x + y) * 10

The JavaScript language has several types of operators:

Type instance description assignment, arithmetic and bit operators = +-* / describe conditions in the JS operator, comparison and logical operators = =! = describe JavaScript statements in the JS comparison operator

In HTML, the command issued by the JavaScript statement to the browser.

Statements are separated by semicolons:

X = 5 + 6 × y = x * 10 × JavaScript keyword

The JavaScript keyword identifies the action to be performed.

Like any other programming language, JavaScript reserves some keywords for its own use.

The var keyword tells the browser to create a new variable:

Var x = 5 + 6 × var y = x * 10

JavaScript also retains some keywords that are not used in the current language version, but will be used in future JavaScript extensions.

The following are the most important reserved words (in alphabetical order) in JavaScript:

Abstractelseinstanceofsuper

Booleanenumintswitch

Breakexportinterfacesynchronized

Byteextendsletthis

Casefalselongthrow

Catchfinalnativethrows

Charfinallynewtransient

Classfloatnulltrue

Constforpackagetry

Continuefunctionprivatetypeof

Debuggergotoprotectedvar

Defaultifpublicvoid

Deleteimplementsreturnvolatile

Doimportshortwhile

Doubleinstaticwith

Show details

JavaScript comment

Not all JavaScript statements are "commands". The content after the double slash / / is ignored by the browser:

/ / I will not execute the JavaScript data type

JavaScript has a variety of data types: numbers, strings, arrays, objects, and so on:

Var length = 16; / / Number is assigned by numeric literal var points = x * 10; / / Number is assigned by expression literal var lastName = "Johnson"; / / String is assigned by literal string var cars = ["Saab", "Volvo", "BMW"] / / Array assigns values through array literals var person = {firstName: "John", lastName: "Doe"}; / / Object assigns the concept of data types through object literals

Data type is a very important content in programming language.

In order to manipulate variables, it is important to understand the concept of data types.

If the data type is not used, the following instances cannot be executed:

16 + "Volvo"

16 how is the addition of "Volvo" calculated? Will the above result in an error or output the following result?

"16Volvo"

You can try to execute the above code in the browser to see the effect.

You will learn more about data types in the following chapters.

JavaScript function

JavaScript statements can be written in functions, and functions can be referenced repeatedly:

Reference a function = call the function (execute the statement within the function).

Function myFunction (a, b) {return a * b; / returns the result of a multiplied by b} JavaScript letter case

JavaScript is case-sensitive.

When writing JavaScript statements, be careful to turn off the case switch key.

The function getElementById is different from getElementbyID.

Similarly, the variables myVariable and MyVariable are different.

JavaScript character set

JavaScript uses the Unicode character set.

Unicode covers all characters, including characters such as punctuation.

This is the end of the content about "what is the literal quantity of JavaScript"? thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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