JS Syntax

HTML
CSS
C#
SQL

Understanding the JavaScript Syntax

The syntax of JavaScript is the set of rules that define a correctly structured JavaScript program.

JavaScript consists of JavaScript statements that are placed within the <script> </script> HTML tags in a web page, or within the external JavaScript file having a .js extension.

Example :

In the example above, you have JavaScript statements assigning values to variables and performing an addition operation, with the result displayed using document.write(). Further explanations of each statement will be covered in upcoming chapters.

Case Sensitivity in JavaScript

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. Similarly, the method name getElementById() must be typed with the exact case not as getElementByID().

Course Video

Examples for Practice

You have to solve all the questions given below in the editor without copy-pasting.

1. Write a Program to print “My First JS Program” to the console.

Here’s a simple JavaScript program that prints “My First JS Program” to the console:

console.log(“My First JS Program”);  

Output

This program uses the `console.log()` function to output the specified string to the console.

2. Write a Program to print “Hello World” to the console.

Here’s a basic JavaScript program that prints “Hello, World!” to the console:

console.log(“Hello, World!”);

Output