Category JavaScript

JavaScript Functions

A JavaScript function is a block of code designed to perform a particular task. A JavaScript function is executed when “something” invokes it (calls it). Example // Function to compute the product of p1 and p2 function myFunction(p1, p2) {…

JavaScript Data Types

JavaScript has 8 Datatypes String Number Bigint Boolean Undefined Null Symbol Object The Object Datatype The object data type can contain both built-in objects, and user defined objects: Built-in object types can be: objects, arrays, dates, maps, sets, intarrays, floatarrays,…

JavaScript Assignment

JavaScript Assignment Operators Assignment operators assign values to JavaScript variables. Operator Example Same As = x = y x = y += x += y x = x + y -= x -= y x = x – y *=…

JavaScript Arithmetic

JavaScript Arithmetic Operators Arithmetic operators perform arithmetic on numbers (literals or variables). Operator Description + Addition – Subtraction * Multiplication ** Exponentiation (ES2016) / Division % Modulus (Remainder) ++ Increment — Decrement

JavaScript Operators

Javascript operators are used to perform different types of mathematical and logical computations. Examples: The Assignment Operator = assigns values The Addition Operator + adds values The Multiplication Operator * multiplies values The Comparison Operator > compares values JavaScript Assignment…

JavaScript Const

The const keyword was introduced in ES6 (2015) Variables defined with const cannot be Redeclared Variables defined with const cannot be Reassigned Variables defined with const have Block Scope Cannot be Reassigned A variable defined with the const keyword cannot…

JavaScript Let

The let keyword was introduced in ES6 (2015) Variables declared with let have Block Scope Variables declared with let must be Declared before use Variables declared with let cannot be Redeclared in the same scope Block Scope Before ES6 (2015),…

JavaScript Variables

Variables are Containers for Storing Data JavaScript Variables can be declared in 4 ways: Automatically Using var Using let Using const In this first example, x, y, and z are undeclared variables. They are automatically declared when first used: Example…

JavaScript Comments

JavaScript comments can be used to explain JavaScript code, and to make it more readable. JavaScript comments can also be used to prevent execution, when testing alternative code. Single Line Comments Single line comments start with Any text between…