본문으로 건너뛰기

Operators

Operators

In programming, symbols like addition (+), subtraction (-), multiplication (×), and division (÷) are called operators.

Operators are used to process data (values) and to create new values.


Basic Operators

  1. Arithmetic Operators
    These operators perform basic mathematical operations.
  • + : Addition

  • - : Subtraction

  • * : Multiplication

  • / : Division

  • % : Remainder

let result = 5 * 3; // result is 15.

  1. Comparison Operators
    These operators compare the magnitude of values or variables and return true or false values.
  • == : Equal (compares only value)

  • === : Strictly equal (compares value and type)

  • != : Not equal

  • !== : Strictly not equal

  • > : Greater than

  • < : Less than

  • >= : Greater than or equal to

  • <= : Less than or equal to


let isTrue = 5 > 3; // isTrue becomes true.

  1. Logical Operators
    These are used to combine multiple conditions to determine true or false values.
  • && : AND

  • || : OR

  • ! : NOT

let value = true && false; // value becomes false.

Special Operators

  • Ternary Operator
    Allows you to express a simple conditional statement in one line.
    (condition) ? value1 : value2

let age = 15;
let type = age >= 20 ? 'adult' : 'teen'; // type is "teen".

다음 내용이 궁금하다면?

월 12,500원 PLUS 멤버십 가입 or 강의를 등록해 주세요!