The building blocks of programming languages are their statements, functions, and data types.
A function is a collection of reusable code that can be used at any point in the software. The same code does not need to be rewritten. It facilitates the writing of modular code by programmers. A programmer may use functions to break down a large program into smaller, more manageable functions.
In JS, declaring a variable is done with the var statement.
Watch the video below for demonstrations of declaring a function and variable!
“If” statements: When a condition is true, it is used to signify that a block of code should be executed.
“Else” statements: The execution of a block of code is defined when the same condition is incorrect.
“Else if” statements: If the first condition is incorrect, this determines a new test.
Switch: It can be used to define a variety of different code blocks to run.
Looping is a feature in programming languages that allows a set of instructions/functions to be repeated until some condition evaluates to true.
Types of Loop
Entry Controlled Loops: An entry controlled loop is any loop in which we verify the test condition before entering it. The test condition in these loops decides whether or not the program enters the loop. For example, while, for, and so on.
Exit Controlled Loops: An exit controlled loop is one in which the test condition is checked after each statement has been executed. The test condition specifies whether the program will exit the loop or not in these loops. Doing...while loop falls under this category.
A while loop is a control flow statement that permits code to be performed repeatedly if a Boolean condition is met. The while loop is similar to an if statement that repeats itself.
For… In Loop
Do While Loop
Primitive Data Type
A primitive data value is a single basic data value that does not have any additional properties or methods. It consists of the data types mentioned below.
String: Textual data is represented using the string data type.
Number: As the name suggests, it is used for representing numerical data.
Boolean: True or false are the two possible values for this data type.
Undefined: It is a data type with an uninitialized variable.
Null: A data form with no value is denoted by null.
Non-Primitive Data Type
This data type can store both simple and complex entities.
Object: In the form of "key: value" pairs, an unordered set of related data of primitive or reference forms is called an object. In the context of an object, these keys may be variables or functions, and they are referred to as properties and methods, respectively.
Array: An array can contain several values under a single name, and the values can be accessed by referring to an index number.
RegExp: The RegExp object is used to find text that matches a sequence.