Detailed explanation of js expressions and operator codes
This article mainly shares with you detailed examples of js expressions and operator codes. I hope it can help you.
/**
* Created by Administrator on 2017/12/14.
* 表达式与运算符
*/
//1.基本表达式 加减乘除
var a = 4;
a = 7/6;
var b = (a + 4)/2;
console.log(a);
console.log(b);
console.log("==========");
//end
//2.比较运算符 == != > < >= <=
console.log(a <= b);
console.log(a == b);
console.log(a != b);
console.log("==========");
//end
//3.逻辑表达式 逻辑与(&&)和逻辑或(||)
var ret = (a > 1) && (a < 2);
console.log(ret);
console.log(true && false);
console.log("==========");
//end
//4.字符串
a = 10;
b = 20;
var num_str = "" + a + b + true;
console.log(num_str); //1020true
num_str = a + b + true + "";
console.log(num_str); //31
console.log("==========");
//end
//5.简约表达式 += -= *= /= ++ --
var c = null;
a += c; //a = a + c
a -= c; //a = a - c
a *= c; //a = a * c
a /= c; //a = a / c
a = 10;
a++; //a = a + 1 先参与运算,最后自增
++a; //a = a + 1 先自增在参与运算
console.log(a);
a--; //a = a - 1 先参与运算,最后自减
console.log(a);
--a; //a = a - 1 先自减在参与运算
a = 4;
console.log(a++);
console.log(++a);
// endRelated recommendations:
js expression calculator code_javascript skills
The 20 most commonly used regular expressions in JavaScript
The above is the detailed content of Detailed explanation of js expressions and operator codes. For more information, please follow other related articles on the PHP Chinese website!
Hot AI Tools
Undresser.AI Undress
AI-powered app for creating realistic nude photos
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undress AI Tool
Undress images for free
Clothoff.io
AI clothes remover
AI Hentai Generator
Generate AI Hentai for free.
Hot Article
Hot Tools
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Hot Topics
1378
52
WebSocket and JavaScript: key technologies for implementing real-time monitoring systems
Dec 17, 2023 pm 05:30 PM
WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology
Analysis of the meaning and usage of += operator in C language
Apr 03, 2024 pm 02:27 PM
The += operator is used to add the value of the left operand to the value of the right operand and assign the result to the left operand. It is suitable for numeric types and the left operand must be writable.
JavaScript and WebSocket: Building an efficient real-time weather forecasting system
Dec 17, 2023 pm 05:13 PM
JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We
Simple JavaScript Tutorial: How to Get HTTP Status Code
Jan 05, 2024 pm 06:08 PM
JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest
Mind map of Python syntax: in-depth understanding of code structure
Feb 21, 2024 am 09:00 AM
Python is widely used in a wide range of fields with its simple and easy-to-read syntax. It is crucial to master the basic structure of Python syntax, both to improve programming efficiency and to gain a deep understanding of how the code works. To this end, this article provides a comprehensive mind map detailing various aspects of Python syntax. Variables and Data Types Variables are containers used to store data in Python. The mind map shows common Python data types, including integers, floating point numbers, strings, Boolean values, and lists. Each data type has its own characteristics and operation methods. Operators Operators are used to perform various operations on data types. The mind map covers the different operator types in Python, such as arithmetic operators, ratio
How to get HTTP status code in JavaScript the easy way
Jan 05, 2024 pm 01:37 PM
Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service
Python Operators: The Ultimate Guide from Newbie to Master
Mar 11, 2024 am 09:13 AM
Introduction to python operators Operators are special symbols or keywords used to perform operations between two or more operands. Python provides a variety of operators covering a wide range of uses, from basic mathematical operations to complex data manipulation. Mathematical operators Mathematical operators are used to perform common mathematical operations. They include: operator operation examples + addition a + b - subtraction a-b * multiplication a * b / division a / b % modulo operation (take the remainder) a % b ** power operation a ** b // integer division (discard the remainder) a//b Logical Operators Logical operators are used to concatenate Boolean values and evaluate conditions. They include: operator operations examples and logical and aandbor logical or aorbnot logical not nota comparison operations
How to sort operator precedence in go language
Dec 21, 2023 pm 05:03 PM
In Go language, operators are evaluated in order from high to low precedence. The priority order of common operators: 1. Parentheses: () (highest priority, used to force the order of operations); 2. Unary operators; 3. Multiplicative operators; 4. Additive operators; 5. Shift operator; 6. Bitwise operator; 7. Comparison operator; 8. Logical operator; 9. Conditional operator (ternary operator); 10. Assignment operator, etc.


