JavaScript Basics Operators

JavaScript Basics Operators

1. Operators

Operators, also known as operators, are symbols used to implement functions such as assignment, comparison, and arithmetic operations.

Commonly used operators in JavaScript are:

  • Arithmetic operators (+, -, *, /, %)
  • Increment and decrement operators (++num, num++, --num, num--)
  • Comparison Operators
  • Logical operators
  • Assignment Operators

Assignment operation:

var a = 1; //Put the value on the right into the variable on the left

Comparison operations:

  • Comparison operation - refers to the comparison of the size of numbers: > < >= <=
  • The result of the comparison operation must be a Boolean value.

Logical operations:

  • Logical operators: && (and) || (or) ! Not/invert
  • && and || are used to connect two conditions to form a large conditional judgment result

Increment and decrement operations:

++ Increment symbol

When the ++ symbol encounters the output, the symbol is at the back, so ++ is performed last and the output is performed first

console.log( a++ );

When the ++ symbol encounters the output, the symbol comes first, so ++ is performed first, and then the output

console.log(++a);

The same applies to the minus sign

--Decrement symbol

Summarize

This article ends here. I hope it can be helpful to you. I also hope that you can pay more attention to more content on 123WORDPRESS.COM!

You may also be interested in:
  • This article summarizes the characteristics of logical operators in JS
  • Let's take a look at the same old JS operator explanation
  • Detailed explanation of JS operator precedence and expression examples
  • Simple usage examples of JS operators
  • JavaScript equality operator nine rules with examples
  • Detailed explanation of || and && operators in js
  • Detailed explanation of operator overloading in Javascript
  • Explanation of operators in JavaScript

<<:  HTML scroll bar textarea attribute setting

>>:  Use of MySQL triggers

Recommend

MySQL 8.0.14 installation and configuration method graphic tutorial (general)

MySQL service 8.0.14 installation (general), for ...

Discussion on more reasonable creation rules for MySQL string indexes

Preface Regarding the use of MySQL indexes, we ha...

Detailed explanation of reduce fold unfold usage in JS

Table of contents fold (reduce) Using for...of Us...

Introduction to /etc/my.cnf parameters in MySQL 5.7

Below are some common parameters of /etc/my.cnf o...

Teach you how to make cool barcode effects

statement : This article teaches you how to imple...

How to dynamically add ports to Docker without rebuilding the image

Sometimes you may need to modify or add exposed p...

A brief discussion on the magical uses of CSS pseudo-elements and pseudo-classes

CSS plays a very important role in a web page. Wi...

Html+CSS drawing triangle icon

Let’s take a look at the renderings first: XML/HT...

Difference between var and let in JavaScript

Table of contents 1. Scopes are expressed in diff...

Login interface implemented by html+css3

Achieve results First use HTML to build a basic f...