JavaScript operators
Operator = is used for assignment.
Operator + is used to add value.
Operator = is used to assign values to JavaScript variables.
The arithmetic operator + is used to add values.
Example
php中文网(php.cn) 点击按钮计算 x 的值.
Run the program and try it
JavaScript Arithmetic Operators
Arithmetic operators are used to perform arithmetic operations between variables and/or values.
Given y=5, the following table explains these arithmetic operators:
Operator | Description | Example | Result |
---|---|---|---|
+ | Add | x=y+2 | x=7 |
- | minus | x=y-2 | x=3 |
* | Multiply | x=y*2 | x=10 |
/ | divide | x=y/2 | x=2.5 |
Find the remainder (keep the integer) | x=y%2 | x=1 | |
accumulation | x=++y | x=6 | |
Decreasing | x=--y | x=4 |
JavaScript assignment operator
The assignment operator is used to assign values to JavaScript variables. Given x=10 and y=5, the following table explains the assignment operators:+ operator for strings
+ operator is used to convert a text value or String variables are added together (concatenated).
To connect two or more string variables, please use the + operator.
Example
If you need to connect two or more string variables, please use the + operator:
php中文网(php.cn) 点击按钮创建及增加字符串变量。
Run the program and try it
To add spaces between two strings, you need to insert spaces into a string:
php中文网(php.cn) 点击按钮创建及增加字符串变量。
Run the program and try it
Or insert spaces into the expression:
php中文网(php.cn) 点击按钮创建及增加字符串变量。
Run the program and try it
Add strings and numbers
Add two numbers and return the sum of the added numbers. If a number is added to a string, a string is returned. The following example:
Example
php中文网(php.cn) 点击按钮创建及增加字符串变量。
Rule: If you add a number to a string, the result will be a string!
Run the program and try it
- Course Recommendations
- Courseware download
-
IntermediateFront-end Vue3 actual combat [handwritten vue project]
2857 people are watching -
ElementaryAPIPOST tutorial [Popularization of technical concepts related to network communication]
1795 people are watching -
IntermediateIssue 22_Comprehensive actual combat
5521 people are watching -
ElementaryIssue 22_PHP Programming
5172 people are watching -
ElementaryIssue 22_Front-end development
8713 people are watching -
IntermediateBig data (MySQL) video tutorial full version
4525 people are watching -
ElementaryGo language tutorial-full of practical information and no nonsense
2794 people are watching -
ElementaryGO Language Core Programming Course
2814 people are watching -
IntermediateJS advanced and BootStrap learning
2563 people are watching -
IntermediateSQL optimization and troubleshooting (MySQL version)
3374 people are watching -
IntermediateRedis+MySQL database interview tutorial
2963 people are watching -
ElementaryDeliver food or learn programming?
5708 people are watching
Students who have watched this course are also learning
- Let's briefly talk about starting a business in PHP
- Quick introduction to web front-end development
- Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
- Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
- Login verification and classic message board
- Computer network knowledge collection
- Quick Start Node.JS Full Version
- The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
- Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
- About us Disclaimer Sitemap
- php.cn:Public welfare online PHP training,Help PHP learners grow quickly!
Example | is equivalent to | Result | |
---|---|---|---|
x=y | x=5 | ||
x+=y | x=x+y | x=15 | |
x-=y | x=x-y | x=5 | |
x*=y | x=x*y | x=50 | |
x/=y | x=x/y | x=2 | |
x%=y | x=x%y | x=0 |