Arrow functions in JavaScript

Arrow functions Arrow functions are, as the name suggests, functions defined with a new syntax that uses an arrow (=>) as part of the syntax. The arrow function definition consists of a parameter list followed by the => marker, which is followed by a function body. For example, (param1, param2, …, paramN) => { statements […]

JavaScript Scope

Scope   In JavaScript, scope refers to the current context of code. A variable’s scope is the context in which the variable exists. The scope specifies from where you can access a variable and whether you have access to the variable in that context. In JavaScript, a variable can be globally or locally defined   […]

JavaScript Switch statement

Switch statement   Switch statement starts with a variable called Switch value. This is the variable whose value if compared in each case statement within the switch. Each case statement indicates a possible value for the variable and subsequent code that should run if the variable matches the case value.   Example of Switch statement […]

JavaScript Objects

Objects provide a way of organizing variables and functions into logical groups. The variables are called properties and functions are called methods of the object. JavaScript has several predefined objects like Math, String etc. However, sometimes we may need to create custom objects.   Creating Objects in JavaScript There are two options to create custom […]

JavaScript functions

functions   A function is seen as a wrapper to a block of code that is given a name. They can be executed from other areas of the program using the name. We can define functions using the function keyword : function hello(){ alert("Hello"); } The above code creates a function named hello.   We […]