JavaScript comparison and operator (i)

Source: Internet
Author: User
Tags logical operators

1.JavaScript operator

operator = is used to assign a value.

operator + is used to add values.

y=5; z=2; x=y+z;

1.1 + Operators for strings

The + operator is used to add a literal value or a string variable (to join together).

If you want to concatenate two or more string variables, use the + operator.

txt1="whata very", txt2="Nice Day"; txt3= TXT1+TXT2;
The results of the TXT3 operation are as follows:
What a Verynice Day

1.2 Adding arithmetic to strings and numbers

Two numbers are added, the sum of the numbers is returned, and if the number is added to the string, the string is returned as follows:

x=5+5; y="5"+5; z="  Hello"+5;

x,y, and z output results are:

Ten  - Hello5

2.JavaScript comparison and logical operators

Comparison and logical operators are used to test for true or false.

2.1 comparison operators

Comparison operators are used in logical statements to determine whether a variable or value is equal.

X=5, the following table explains the comparison operators:

2.2 Logical operators

Logical operators are used to determine the logic between variables or values.

Given X=6 and y=3, the following table explains the logical operators:

2.3 Bar Operators

JavaScript also includes conditional operators that assign values to variables based on certain conditions.

JavaScript comparison and operator (i)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.