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 comparison operators and logical operators

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

Share

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

This article mainly shows you "JavaScript comparison operator and logic operator how to use", the content is easy to understand, clear, hope to help you solve doubts, the following let Xiaobian lead you to study and learn "JavaScript comparison operator and logic operator how to use" this article.

JavaScript data type

String, number, Boolean, array, object, Null, Undefined

JavaScript has dynamic types

JavaScript has dynamic types. This means that the same variable can be used as different types:

Var x / / x is undefinedvar x = 6; / / x is a number var x = "Bill"; / / x is a string

JavaScript string

A string is a variable that stores characters, such as "Bill Gates".

The string can be any text in quotation marks. You can use single or double quotation marks:

Var carname= "Bill Gates"; var carname= "Bill Gates"

You can use quotation marks in a string, as long as they do not match the quotation marks that surround the string:

Var answer= "Nice to meet you!"; var answer= "He is called" Bill ""; var answer= "He is called" Bill ""

JavaScript digit

JavaScript has only one numeric type. Numbers can be decimal or not:

Var x1 to 34. 00; / / write var x2 to 34 with decimal point; / / write without decimal point

Very large or very small numbers can be written by scientific (exponential) counting:

Var yearly 123e5; / / 12300000var zonal 123eMur5; / / 0.00123

JavaScript Boolean

Boolean (logical) can only have two values: true or false. Boolean is often used in conditional testing.

Var x=truevar y=false

JavaScript array

The following code creates an array named cars:

Var cars=new Array (); cars [0] = "Audi"; cars [1] = "BMW"; cars [2] = "Volvo"

Or (condensed array):

Var cars=new Array ("Audi", "BMW", "Volvo")

Or (literal array):

Var cars= ["Audi", "BMW", "Volvo"]

Example

Var i; var cars = new Array (); cars [0] = "Audi"; cars [1] = "BMW"; cars [2] = "Volvo"; for

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