JavaScript Syntax
JavaScript Tutorial » JavaScript Syntax
JavaScript Syntax is a set of rules that define a structured JavaScript program
Syntax:a = 5; b = 6; // is Assign Values
c = a + b; // is Compute Values
JavaScript Values - example
JS syntax defines two types of values:
- Fixed values named Literals
- Variable values named Variables
JavaScript Literals
1. Numbers are written with or without decimals:
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Numbers</h2>
<p>This is an example with Number and this <br />
can be written with or without decimals.</p><p id="test"></p>
<script>
</body>
document.getElementById("test").innerHTML = 24.67;
</script>
</html>
2. Strings are text, within single or double quotes:
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Strings</h1>
<p>Strings are text, within single or double quotes,
<br /> example: </p><p id="text"></p>
<script>
</body>
document.getElementById("text").innerHTML = 'Jon Bon Jovi';
</script>
</html>
JavaScript Variables, example
In JS, variables are used to store data values.
An equal sign (=) is used to assign values to variables.
<!DOCTYPE html>
<html>
<body>
<h1>JS Variables</h1>
<p>(a) is defined as a variable.<br />
and a is assigned the value of 15:</p><p id="test"></p>
<script>
</body>
var a;
a = 15;
document.getElementById("test").innerHTML = a;
</script>
</html>
Case Sensitivity in JavaScript - example
JavaScript is case-sensitive.
This means that variables, language keywords, function names, and other identifiers must always be typed with a consistent capitalization of letters.
For example, the variable myVar must be typed myVar not MyVar or myvar
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Case Sensitivity</title>
</head>
<body>
<script>
var myVar = "Hi, nice to knoe JavaScript";
console.log(myVar);
console.log(MyVar);
console.log(myvar);
</script>
<p><strong>Note:</strong> Check out the browser console by pressing the f12 key on the keyboard, you'll see a line something like this: "Uncaught ReferenceError: MyVar is not defined".</p>
</body>
</html>
Syntax checker, in html, online, for printing values in console, highlighter vscode, documentation, if statemjent with two conditions, pdf
JavaScript Syntax - javascript tutorial
This tool makes it easy to create, adjust, and experiment with custom colors for the web.

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.

Find here examples of creative and unique website layouts.

Find here examples of creative and unique website CSS HTML menu.