JavaScript: A Basic Example
Posted: Sun Aug 03, 2025 9:15 am
Code: Select all
<!DOCTYPE html>
<html>
<head><title>JavaScript Examples</title></head>
<body>
<script>
let x = 2;
// The line above represents the declaration of a variable with the integer value of 2.
// The integer data type, as with other ones, is not declared.
window.alert("1 + 1 is" + x + ".");
// The line above outputs "1 + 1 is 2." on window.
</script>
</body>
</html>