Javascript Advanced Concepts Explanation
candies

WARNING: Commenting will automatically update you once I updated.

Welcome to JACE!
Here youll learn everything you need to know about Javascript. Lets get started!

Statements

JavaScript statements are composed of:

Values, Operators, Expressions, Keywords, and Comments.

This statement tells the browser to write "Hello Dolly." inside an HTML element with id="demo":

Most JavaScript programs contain many JavaScript statements.

The statements are executed, one by one, in the same order as they are written.

Semicolons ;

Semicolons separate JavaScript statements.
Add a semicolon at the end of each executable statement:

When separated by semicolons, multiple statements on one line are allowed:

Conditional Statements

IF..Else

Very often when you write code, you want to perform different actions for different decisions.

You can use conditional statements in your code to do this.

In JavaScript we have the following conditional statements:

  1. Use if to specify a block of code to be executed, if a specified condition is true
  2. Use else to specify a block of code to be executed, if the same condition is false
  3. Use else if to specify a new condition to test, if the first condition is false
  4. Use switch to specify many alternative blocks of code to be executed

JavaScript Comparison and Logical Operators

Comparison and Logical operators are used to test for true or false.

Comparison Operators

Comparison operators are used in logical statements to determine equality or difference between variables or values.

Given that x = 5, the table below explains the comparison operators:

Operator:Description:Comparing:
==equal toox == 8
===equal value and equal typex === 5
!=not equalx != 8
!==not equal value or not equal typex !== 5
>greater thanx > 8
<less thanx < 8
>=greater than or equal tox >= 8
<=less than or equal tox <= 8

How Can it be Used

Comparison operators can be used in conditional statements to compare values and take action depending on the result:

Logical Operators

Logical operators are used to determine the logic between variables or values.

Conditional (Ternary) Operator

JavaScript also contains a conditional operator that assigns a value to a variable based on some condition.

Syntax

Example

for/in Statement

Example

Loop through the properties of an object:

Definition and Usage

The for/in statement loops through the properties of an object.
The block of code inside the loop will be executed once for each property.

JavaScript supports different kinds of loops:
for - loops through a block of code a number of times
for/in - loops through the properties of an object
for/of - loops through the values of an iterable object
while - loops through a block of code while a specified condition is true
do/while - loops through a block of code once, and then repeats the loop while a specified condition is true

Note: Do not use the for/in statement to loop through arrays where index order is important. Use the for statement instead.

Syntax

Thanks for reading! Adding more stuff soon!

Changelog

Added for/in Statement [Section]

You are viewing a single comment. View All
candies

@Bookie0 pyyoutube = download videos & get video stats