Operator JavaScript

CODEORAYO COMMUNITY Web Development Tutorial Javascript Operator JavaScript

  • Post
    codeorayo
    Keymaster
    none
    Operator JavaScript adalah simbol yang digunakan untuk melakukan operasi pada operan

    Contoh :

    Code:

    var sum=10+20;

    Di sini, + adalah operator aritmatika dan = adalah operator penugasan.

    Ada beberapa jenis operator dalam JavaScript :

    [list=*]

  • Operator Aritmatika
  • [*]Operator Perbandingan (Relasional)
  • [*]Operator Bitwise
  • [*]Operator logic
  • [*]Operator Penugasan
  • [*]Operator Khusus
  • [/list]

    Operator Aritmatika JavaScript

    Operator aritmatika digunakan untuk melakukan operasi aritmatika pada operan. Operator berikut dikenal sebagai operator aritmatika JavaScript.

    [list=*]

  • [*]+ Addition 10+20 = 30
  • [*] – Subtraction 20-10 = 10
  • [*] * Multiplication 10*20 = 200
  • [*] / Division 20/10 = 2
  • [*] % Modulus (Remainder) 20%10 = 0
  • [*] ++ Increment var a=10; a++; Now a = 11
  • [*] — Decrement var a=10; a–; Now a = 9
  • [/list]

    Operator Perbandingan JavaScript

    Operator perbandingan JavaScript membandingkan dua operan.

    [list=*]

  • [*] == Is equal to 10==20 = false
  • [*] === Identical (equal and of same type) 10==20 = false
  • [*] != Not equal to 10!=20 = true
  • [*] !== Not Identical 20!==20 = false
  • [*] > Greater than 20>10 = true
  • [*] >= Greater than or equal to 20>=10 = true
  • [*] < Less than 20<10 = false
  • [*] <= Less than or equal to 20<=10 = false
  • [/list]

    Operator Bitwise JavaScript

    Operator bitwise melakukan operasi bitwise pada operan.

    [list=*]

  • [*]& Bitwise AND (10==20 & 20==33) = false
  • [*] | Bitwise OR (10==20 | 20==33) = false
  • [*] ^ Bitwise XOR (10==20 ^ 20==33) = false
  • [*] ~ Bitwise NOT (~10) = -10
  • [*] << Bitwise Left Shift (10<<2) = 40
  • [*] >> Bitwise Right Shift (10>>2) = 2
  • [*] >>> Bitwise Right Shift with Zero (10>>>2) = 2
  • [/list]

    Operator Logika JavaScript

    [list=*]

  • [*]&& Logical AND (10==20 && 20==33) = false
  • [*] || Logical OR (10==20 || 20==33) = false
  • [*] ! Logical Not !(10==20) = true
  • [/list]

    Operator Penugasan JavaScript [list=*]

  • [*] = Assign 10+10 = 20
  • [*] += Add and assign var a=10; a+=20; Now a = 30
  • [*] -= Subtract and assign var a=20; a-=10; Now a = 10
  • [*] *= Multiply and assign var a=10; a*=20; Now a = 200
  • [*] /= Divide and assign var a=10; a/=2; Now a = 5
  • [*] %= Modulus and assign var a=10; a%=2; Now a = 0
  • [/list]

    Operator Khusus JavaScript

    [list=*]

  • [*](? :) – Operator Bersyarat mengembalikan nilai berdasarkan kondisi. Ini seperti jika ada yang lain.
  • [*] , -Operator Comma memungkinkan beberapa ekspresi dievaluasi sebagai pernyataan tunggal.
  • [*] delete – Delete Operator menghapus properti dari objek.
  • [*] in – Operator memeriksa apakah objek memiliki properti yang diberikan
  • [*] instanceof – memeriksa apakah objek adalah instance dari tipe yang diberikan
  • [*] new – membuat instance (objek)
  • [*] typeof – memeriksa jenis objek.
  • [*] void – membuang nilai kembali ekspresi.
  • [*]yield – memeriksa apa yang dikembalikan dalam generator oleh iterator generator.
  • [/list]

    Author: Javatpoint, Translated by Codeorayo

  • You must be logged in to reply to this topic.