JavaScript syntax

 JavaScript syntax

// How to create variables:
var x;
let y;

// How to use variables:
x = 5;
y = 6;
let z = x + y;


The two most important syntax rules for fixed values are:

1. Numbers are written with or without decimals:

10.50

1001


2. Strings are text, written within double or single quotes:

example:

"John Doe"

'John Doe'


JavaScript Variables

In a programming language, variables are used to store data values.

JavaScript uses the keywords varlet and const to declare variables.

An equal sign is used to assign values to variables.

In this example, x is defined as a variable. Then, x is assigned (given) the value 6:

example :

let x;
x = 6;

JavaScript Operators

JavaScript uses arithmetic operators ( + - * / ) to compute values:
example :

JavaScript uses an assignment operator ( = ) to assign values to variables:
example :
let x, y;
x = 5;
y = 6;

JavaScript Expressions
An expression is a combination of values, variables, and operators, which computes to a value.

The computation is called an evaluation.

For example, 5 * 10 evaluates to 50:

example :
5 * 10
Expressions can also contain variable values:
The values can be of various types, such as numbers and strings.

For example, "John" + " " + "Doe", evaluates to "John Doe":

example :
"John" + " " + "Doe"


(5 + 6) * 10

Comments

Popular posts from this blog

C Program to Display the ATM Transaction

Fortran

Java programming language