| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Guide/Expressions_and_operators | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
JavaScript , , , , , , .
JavaScript . , .
JavaScript , . .
1 2
3+4 x*y .
.
x++ ++x .
.
(=), x = y y x
.
, .
x = y |
x = y |
|
x += y |
x = x + y |
|
x -= y |
x = x - y |
|
x *= y |
x = x * y |
|
x /= y |
x = x / y |
|
x %= y |
x = x % y |
|
x **= y |
x = x ** y |
|
x <<= y |
x = x << y |
|
x >>= y |
x = x >> y |
|
x >>>= y |
x = x >>> y |
|
| AND | x &= y |
x = x & y |
| XOR | x ^= y |
x = x ^ y |
| OR | x |= y |
x = x | y |
| AND | x &&= y |
x && (x = y) |
| OR | x ||= y |
x || (x = y) |
x ??= y |
x ?? (x = y) |
let obj = {};
obj.x = 3;
console.log(obj.x); // 3 .
console.log(obj); // { x: 3 } .
const key = "y";
obj[key] = 5;
console.log(obj[key]); // 5 .
console.log(obj); // { x: 3, y: 5 } .
, .
let val = 0;
console.log((val.x = 3)); // 3 .
console.log(val.x); // undefined .
console.log(val); // 0 .
, (null undefined) .
var foo = ["one", "two", "three"];
//
var one = foo[0];
var two = foo[1];
var three = foo[2];
//
var [one, two, three] = foo;
// x f() ,
// x = f() .
let x = f();
// x g() ,
// x = g() .
x = g(); // x g() .
, x = f() . , .
. , .
let x;
const y = (x = f()); // const y = x = f(); .
console.log(y); // x = f() .
console.log((x = f())); // .
//
//
// .
console.log([0, (x = f()), 0]);
console.log(f(0, (x = f()), 0));
"" = . x = f() f() , x += f() x + f() , x **= f() x ** y .
(x &&= y), (x ||= y), (x ??= y) . x && y, x || y, x ?? y .
, = .
, f, g x, y .
function f() {
console.log("F!");
return 2;
}
function g() {
console.log("G!");
return 3;
}
let x, y;
.
y = x = f();
y = [f(), (x = g())];
x[f()] = g();
= y = x = f() y = (x = f()) . ,
y = x = f() .
y, y .x = f() .
x, x .f() "F!" 2 .f() 2 x .x = f() . x , 2.2 y .y = x = f() . y , 2. x y 2 , "F!" .y = [ f(), x = g() ] .
y = [ f(), x = g() ] .
y, y .[ f(), x = g() ] .
f() "F!" 2 .x = g() .
x, x .g() "G!" 3 .g() 3 x .x = g() . x , 3. 3 . ( f() 2)[ f(), x = g() ] . , [ 2, 3 ].[ 2, 3 ] y .y = [ f(), x = g() ] . y , [ 2, 3 ]. x 3, y [ 2, 3 ] , "F!" "G!" .x[f()] = g() .
x[f()] = g() . x[2] , 3. x[2] 3 , "F!" "G!" . const, let, var , () const/let/var . ,
let z = (y = x = f());
x, y, z . z . y x ([ ][/ko/docs/web/javascript/reference/strict_mode]) , ( ) x y [ ][/ko/docs/glossary/global_variable]
, . , , , . Unicode . , JavaScript . .
=== !== ,
. .
const var1 = 3;
const var2 = 4;
true |
||
|---|---|---|
(==)
|
true . |
3 == var1
3 == '3'
|
(!=)
|
true . |
var1 != 4
|
(===)
|
true .
Object.is
JavaScript .
|
3 === var1 |
(!==)
|
true .
|
var1 !== "3"
|
(>)
|
true .
|
var2 > var1
|
(>=)
|
true
.
|
var2 >= var1
|
(<)
|
true
.
|
var1 < var2
|
(<=)
|
true
.
|
|
( ) .
(+), (-), (*), (/).
. (0
Infinity ) ,
1 / 2; // 0.5
1 / 2 == 1.0 / 2.0; //
JavaScript (+, -, *, /)
.
10, 16, 8 , 32 . , 10 9 2 1001 . , JavaScript .
JavaScript .
| AND | a & b |
1 1 . |
| OR | a | b |
0 0 . |
| XOR | a ^ b |
0 . [ 1 .] |
| NOT | ~ a |
. |
a << b |
a b , 0 . |
|
a >> b |
a b , 1 . |
|
a >>> b |
a b , 1 . 0 . |
, .
32 (0 1) . 32 . 32 .
: 1110 0110 1111 1010 0000 0000 0000 0110 0000 0000 0001 : 1010 0000 0000 0000 0110 0000 0000 0001
. , , , ... 32 32 .
.
, 9 1001, 15 1111. .
15 & 9 |
9 |
1111 & 1001 = 1001 |
15 | 9 |
15 |
1111 | 1001 = 1111 |
15 ^ 9 |
6 |
1111 ^ 1001 = 0110 |
~15 |
-16 |
~ 0000 0000 ... 0000 1111 = 1111 1111 ... 1111 0000 |
~9 |
-10 |
~ 0000 0000 ... 0000 1001 = 1111 1111 ... 1111 0110 |
, NOT 32 , ( ) 1 (2
). ~x -x - 1 .
, . .
32 , Number BigInt .
, BigInt BigInt , Number
.
.
(<<)
|
. , 0 . | 9<<2, 1001 2 100100 36. |
(>>)
|
. , . |
9>>2, 1001 2 10 2.
-9>>2, -3 .
|
(>>>)
|
. , 0 . |
19>>>2, 10011 2 100 4.
.
|
() .
&& || ,
.
.
AND
(&&)
|
expr1 && expr2
|
expr1 false expr1 .
expr2 . , true,
false .
|
OR (||) |
expr1 || expr2 |
expr1 true expr1 .
expr2 . , true,
false .
|
NOT
(!)
|
!expr |
true false .
true .
|
false null, 0, NaN,
(""), undefined .
&& ( AND) .
var a1 = true && true; // t && t true
var a2 = true && false; // t && f false
var a3 = false && true; // f && t false
var a4 = false && 3 == 4; // f && f false
var a5 = "Cat" && "Dog"; // t && t Dog
var a6 = false && "Cat"; // f && t false
var a7 = "Cat" && false; // t && f false
|| ( OR) .
var o1 = true || true; // t || t true
var o2 = false || true; // f || t true
var o3 = true || false; // t || f true
var o4 = false || 3 == 4; // f || f false
var o5 = "Cat" || "Dog"; // t || t Cat
var o6 = false || "Cat"; // f || t Cat
var o7 = "Cat" || false; // t || f Cat
! ( NOT) .
var n1 = !true; // !t false
var n2 = !false; // !f true
var n3 = !"Cat"; // !t false
, ""(short-circuit) .
false && .true || .. , .
|| ,
(??) . " ", null undefined . ''
0 .
, (+)
.
,
console.log(" " + ""); // " "
+= .
,
var mystring = "";
mystring += ""; // "" , mystring ""
condition ? val1 : val2;
condition , val1 , val2
. .
,
var status = age >= 18 ? "" : "";
age 18 status "" ,
"" .
, 10 10 2 a , . a ((0, 0), (1, 1), (2, 2), ...) .
var x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var a = [x, x, x, x, x];
for (var i = 0, j = 9; i <= j; i++, j--);
// ^
console.log("a[" + i + "][" + j + "]= " + a[i][j]);
.
deletedelete . .
delete object.property;
delete object[propertyKey];
delete objectName[index];
, objectName , property ,
propertyKey .
delete , undefined
. delete true ,
false .
delete Math.PI; // false ( )
const myObj = { h: 4 };
delete myobj.h; // true ( )
, delete .
. ,
. undefined .
splice .
typeoftypeof
.
typeof operand;
typeof (operand);
typeof . operand ,
, , . .
.
var myFun = new Function("5 + 2");
var shape = "round";
var size = 1;
var foo = ["Apple", "Mango", "Orange"];
var today = new Date();
typeof .
typeof myFun; // "function"
typeof shape; // "string"
typeof size; // "number"
typeof foo; // "object"
typeof today; // "object"
typeof dontExist; // "undefined"
true null .
typeof true; // "boolean"
typeof null; // "object"
.
typeof 62; // "number"
typeof "Hello world"; // "string"
.
typeof document.lastModified; // "string"
typeof window.length; // "number"
typeof Math.LN2; // "number"
.
typeof blur; // "function"
typeof eval; // "function"
typeof parseInt; // "function"
typeof shape.split; // "function"
.
typeof Date; // "function"
typeof Function; // "function"
typeof Math; // "object"
typeof Option; // "function"
typeof String; // "function"
voidvoid .
void (expression);
void expression;
void . expression
JavaScript . , .
, .
inin
true . .
propNameOrNumber in objectName;
propNameOrNumber , ,
objectName .
in .
//
var trees = ["redwood", "bay", "cedar", "oak", "maple"];
0 in trees; // true
3 in trees; // true
6 in trees; // false
"bay" in trees; // false (
// )
"length" in trees; // true (length Array )
//
"PI" in Math; // true
var myString = new String("coral");
"length" in myString; // true
//
var mycar = { make: "Honda", model: "Accord", year: 1998 };
"make" in mycar; // true
"model" in mycar; // true
instanceofinstanceof
true .
objectName instanceof objectType;
objectName objectType , objectType
Date, Array .
instanceof . ,
.
instanceof theDay Date
. theDay Date , if
.
var theDay = new Date(1995, 12, 17);
if (theDay instanceof Date) {
//
}
. .
.
. [] |
|
| / | () new |
! ~ - + ++ -- typeof void delete |
|
** |
|
| / | * / % |
| / | + - |
<< >> >>> |
|
< <= > >= in instanceof |
|
| / | == != === !== |
| AND | & |
| XOR | ^ |
| OR | | |
| AND | && |
| OR | || |
?: |
|
= += -= **= *= /= %= <<= >>= >>>= &= ^= |= &&= ||= ??= |
|
, |
.
, . (: ) , .
x = 7 . = 7 x
. 7 .
3 + 4 . + 3 4 , 7
.
JavaScript .
JavaScript .
this
this .
this . , this
.
this["propertyName"];
this.propertyName;
, value validate
.
function validate(obj, lowval, hival) {
if (obj.value < lowval || obj.value > hival) console.log(" !");
}
, onchange validate this .
<p>18 99 :</p>
<input type="text" name="age" size="3" />
() . ,
.
var a = 1;
var b = 2;
var c = 3;
//
a + b * c; // 7
//
a + (b * c); // 7
//
//
(a + b) * c; // 9
// ...
a * c + b * c; // 9
.
newnew
. .
var objectName = new objectType([param1, param2, ..., paramN]);
super . , .
super([arguments]); //
super.functionOnParent([arguments]);
This page was last modified on 2026 4 15 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |