<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Belajar</title> </head> <body> <script> // ini adalah komentar single line /* ini contoh penggunaan komentar dengan multi line */ console.log("hello world"); </script> </body> </html>
result + 10 result += 10 result = result - 10 result -= 10 result = result * 10 result *= 10 result = result / 10 result /= 10 result = result % 10 result %= 10
charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Belajar</title> </head> <body> <script> let result = 10; result += 10; document.writeln("<p> result = " + result + "</p>"); result -= 10; document.writeln("<p> result = " + result + "</p>"); result *= 10; document.writeln("<p> result = " + result + "</p>"); result /= 10; document.writeln("<p> result = " + result + "</p>"); result %= 10; document.writeln("<p> result = " + result + "</p>"); </script> </body> </html>
data Operasi perbandingan adalah operasi yang menghasilkan nilai boolean (benar atau salah) Jika hasil operasinya adalah benar, maka nilainya adalah true Jika hasil operasinya adalah salah, maka nilainya adalah false
/> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Belajar</title> </head> <body> <script> let result = 10; result = 10 < 5; document.writeln("<p> result = " + result + "</p>"); result = 10 > 5; document.writeln("<p> result = " + result + "</p>"); result = 5 === 5; document.writeln("<p> result = " + result + "</p>"); result = 5 !== 5; document.writeln("<p> result = " + result + "</p>"); </script> </body> </html>