Map Map is introduced in JavaScript with ECMAScript 6. A map is simple key-value pair. Any value (both objects and primitive values) may be used as either a key or a value. Creating a Map We can create a new map using syntax : new Map() or new Map([iterable]) Iterable is an Array or …
Continue reading JavaScript MapJavaScript
if statements The most common conditional statement is an if statement. An if statement checks a condition, and if that condition is met, subsequent code block is executed If the condition isn’t met, the code is skipped. if (condition) { // code to run if condition in true; } Example of JavaScript If statement: …
Continue reading JavaScript If, else and else if statementsLoops are used to perform an action a repeated number of times. There is also a conditional aspect to loops, though, as every loop uses a condition to determine whether or not to execute the loop’s contents. while loop Format of while loop is : When the program first encounters the while loop, it …
Continue reading JavaScript loopsAn array is a special type of variable. It doesn’t just store one value; it stores a list of values. Arrays are especially helpful when you do not know how many items a list will contain because, when you create the array, you do not need to specify how many values it will hold. …
Continue reading JavaScript ArraysJavaScript is loosely typed – it doesn’t care what the variables hold. A variable could start off holding a number, then change to holding a character, a word, or anything else you want it to hold. Data Types Even though you don’t have to declare the data type up front, it’s still useful to …
Continue reading JavaScript Data Types