Movatterモバイル変換


[0]ホーム

URL:


Menu
×
See More 
Sign In
+1 Get Certified Upgrade For Teachers Spaces Get Certified Upgrade For Teachers Spaces
   ❮     
     ❯   

Basic JavaScript

JS TutorialJS SyntaxJS VariablesJS OperatorsJS If ConditionsJS LoopsJS StringsJS NumbersJS FunctionsJS ObjectsJS DatesJS ArraysJS Typed ArraysJS SetsJS MapsJS MathJS RegExpJS Data TypesJS ErrorsJS EventsJS ProgrammingJS ReferencesJS Versions

JS Advanced

JS FunctionsJS ObjectsJS ClassesJS IterationsJS AsynchronousJS ModulesJS Meta & ProxyJS HTML DOMJS WindowsJS Web APIJS AJAXJS JSONJS jQueryJS GraphicsJS ExamplesJS Reference


JavaScript Operators Reference


Complete Operators Reference

Revised July 2025

TypeCommon UseExample
AssignmentAssigns values to variablesx = 5
ArithmeticPerforms arithmetic between variablesx = y + 2
ComparisonCompares variablesx > 8
LogicalDefines the logic between variables(x>0 || x>0)
BitwisePerforms bitwise operatins on 32 bits numbersx = 5 & 1
MiscMiscellaneous operatorsvoid(0)

JavaScript Assignment Operators

Assignment operators assign values to JavaScript variables.

Given that x = 10 and y = 5, the table below explains the assignment operators:

OperName / LinkExampleSame AsResult
=Simplex = yx = yx = 5
+=Addx += yx = x + yx = 15
-=Subtractx -= yx = x - yx = 5
*=Multiplyx *= yx = x * yx = 50
/=Dividex /= yx = x / yx = 2
%=Remainderx %= yx = x % yx = 0
:Colonx: 45x = 45x = 45

Logical Assignment Operators

OperName / LinkExampleResult
&&=ANDtrue &&= 10x = 10
||=ORfalse ||= 10x = 10
??=Nullishnull ??= 10x = 10

Learn More:

Study our JavaScript Assignment Tutorial.


JavaScript Arithmetic Operators

Arithmetic operators are used to perform arithmetic between variables and/or values.

Given thaty = 5, the table below explains the arithmetic operators:

OperName / LinkExampleResults
+Additionx = y + 2y=5, x=7
-Subtractionx = y - 2y=5, x=3
*Multiplicationx=y*2y=5, x=10
/Divisionx = y / 2y=5, x=2.5
**Exponentiationx = y ** 2y=5, x=25
%Remainderx = y % 2y=5, x=1
++Incrementx = y++y=6, x=5
++Incrementx = ++yy=6, x=6
--Decrementx = y--y=4, x=5
--Decrementx = --yy=4, x=4
+Unary Plusx= +yx=5
-Unary Negationx= -yx=-5

Learn More:

Study ourJavaScript Arithmetic Tutorial.


JavaScript String Operators

The + operator, and the += operator can also be used to concatenate (add) strings.

Given thatt1 = "Good ",t2 = "Morning",and t3 = "", the table below explains the operators:

OperExamplet1t2t3Try it
+t3 = t1 + t2"Good ""Morning" "Good Morning"Try it »
+=t1 += t2"Good Morning""Morning"Try it »

Learn More:

Study our JavaScript Strings Tutorial.


Javascript Comparison Operators

Comparison operators are used in logical statements to determine equality or difference between variables or values.

Given thatx = 5, the table below explains the comparison operators:

OperName / LinkComparingReturns
==Equal tox == 8false
==Equal tox == 5true
===Strict Equalx === "5"false
===Strict Equalx === 5true
!=Not Equalx != 8true
!==Strict not Equalx !== "5"true
!==Strict not Equalx !== 5false
>Greater thanx > 8false
<Less thanx < 8true
>=Greater or Equalx >= 8false
<=Less or Equalx <= 8true

Learn More:

Study ourJavaScript Comparisons Tutorial.


JavaScript Logical Operators

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

Given thatx = 6 and y = 3, the table below explains the logical operators:

OperName / LinkExample
&&AND (x < 10 && y > 1)
||OR(x === 5 || y === 5)
!NOT !(x === y)
??Nullish Coalescingx ?? y

Learn More:

Study ourJavaScript Logical Tutorial.


JavaScript Bitwise Operators

Bit operators work on 32 bits numbers.Any numeric operand in the operation is converted into a 32 bit number.The result is converted back to a JavaScript number.

OperNameExampleSame asResultDec
&ANDx = 5 & 10101 & 000100011
|ORx = 5 | 10101 | 000101015
~NOTx = ~ 5~0101101010
^XORx = 5 ^ 10101 ^ 000101004
<<Left Shiftx = 5 << 10101 << 1101010
>>>Right Shiftx = 5 >>> 10101 >>> 100102
>>Signed Rightx = 5 >> 10101 >> 100102

Learn More:

Study our JavaScript Bitwise Tutorial.


Miscellaneous JavaScript Operators

Some miscellaneous JavaScript operators are described below.

OperatorName / LinkExample
:Colonage : 45
.Member ofperson.age
[ ]Member ofperson["age"]
?.Optional Chainingx ?. y
...Spread...myArray
( ) ? x : yTernary Conditional(z < 18) ? x : y
( )Expression( x + y )
( )Function CallmyFunction()
=>Arrow Function(a, b) => a + b
newConstructornew Date()
deleteDeletedelete person.age
inRelational in"age" in person
instanceofInstance ofx instanceof Array
typeofType oftypeof "John"
voidVoidvoid(0)
yieldDelegateyield.x


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted ourterms of use,cookies andprivacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved.W3Schools is Powered by W3.CSS.


[8]ページ先頭

©2009-2025 Movatter.jp