사용자 도구

사이트 도구


wiki:javascript:javascript_note:js_operators

JavaScript Operators

  • description : JavaScript Operators
  • author : 오션
  • email : shlim@repia.com
  • lastupdate : 2021-04-20


Source of the article

Example

변수(variables)에 값을 할당하고, 합산합니다.

var x = 5;       // 값 5를 변수 x에 할당
var y = 2;       // 값 2를 변수 y에 할당
var z = x + y;   // 값 7을 변수 z에 할당 (5 + 2)


할당(assignment) 연산자 (=)는 값을 변수에 할당합니다.

Assignment(할당)

var x = 10;


덧셈(addition) 연산자(+)는 숫자를 더합니다.

Adding

var x = 5;
var y = 2;
var z = x + y;


곱셈(mulitiplication) 연산자(*)는 숫자를 곱합니다.

Multiplying

var x = 5;
var y = 2;
var z = x * y;


JavaScript Arithmetic Operators

산술 연산자(Arithmetic Operators)는 숫자에 대한 산술을 수행하는 데 사용됩니다.

Operator Description
+ adddtion(더하기)
- subtraction(빼기)
* Multiplication(곱하기)
** Exponentiation(거듭제곱)
/ Division(나누기)
% Modulus(Division Remainder) 나눗셈의 나머지
++ Invcrement (증가)
-- Decrement (감소)

JavaScript Assignment Operators

할당 연산자(Assignment operators)는 JavaScript 변수에 값을 할당합니다.

Operator Example Same As
= 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


덧셈 할당 연산자(+=)는 변수에 값을 더합니다.

Assignment

var x = 10;
x += 5;       // x = x + 5 = 10 + 5 = 15


JavaScript String Operators

+ 연산자는 문자열(strings)을 더하기(연결하기)에 사용될 수 있습니다.

Example

var txt1 = "John";
var txt2 = "Doe";
var txt3 = txt1 + " " + txt2;    // txt3 : John Doe


+= 할당 연산자는 문자열(string)을 더하기(연결하기)에 사용될 수 있습니다.

Example

var txt1 = "What a very ";
txt1 += "nice day";         // txt1 : What a very nice day


문자열에서 사용될 경우, %%+%%연산자는 연결연산자(concatenation operator)라고 부릅니다.\\

Adding Strings and Numbers

숫자 두 개의 더하는 것은 합계를 반환하지만, 숫자와 문자열을 더하는 것은 문자열을 반환합니다.

Example

var x = 5 + 5;         // x = 10
var y = "5" + 5;       // y = 55
var z = "Hello+ +5;    // z = Hello5

JavaScript Comparison Operators

비교 연산자(Comparison Operators)

Operator Description
== equal to (양쪽이 같다)
=== equal value and equal type (양쪽이 값과 타입이 같다)
!= not equal (양쪽이 같지 않다)
!== not equal value or not equal type ( 값이 같지 않거나 타입이 같지 않다 )
> greater than ( 왼쪽이 더 크다 )
< less than ( 왼쪽이 더 작다, 오른쪽이 더 크다 )
>= greater than or equal to ( 왼쪽이 더 크거나 같다)
less than or equal to ( 오른쪽이 더 크거나 같다)
? ternary operator ( 삼항 연산자 )


JavaScript Logical Operators

논리 연산자(Logical Operators)

Operator Description
&& logical and ( 논리곱 연산자 )
|| logical or ( 논리합 연산자 )
! logical not


JavaScript Type Operators

자료형을 확인

Operator Description
typeof 변수의 자료형을 반환합니다.
instanceof 객체가 지정된 객체의 인스턴스인 경우 true를 반환합니다.
/var/services/web/dokuwiki/data/pages/wiki/javascript/javascript_note/js_operators.txt · 마지막으로 수정됨: 2023/01/13 18:44 (바깥 편집)