Month: September 2020

While loop in Javascript

JavaScript While loop

JavaScript While loop The JavaScript While loop repeats through a block of code, as long as a specified condition is true.JavaScript supports all the necessary loops to ease down the pressure of programming. While writing a program, you may encounter a situation where you need to perform an action over and over again. In such …

JavaScript While loop Read More »

function in javascript

JavaScript Function

A JavaScript Function is a block of code designed to perform a particular task. The main advantages of using JavaScript Function : Code reuse: Define the code once, and use it many times. Use the same code many times with different arguments, to produce different results. JavaScript Function Example Let’s see the simple example of …

JavaScript Function Read More »

Events in JavaScript

JavaScript Events

JavaScript Events: You can write JavaScript code that executes when an event occurs, such as when a user clicks an HTML element, moves the mouse, or submits a form. Common HTML Event: Event Listeners The addEventListener() method attaches an event handler to an element without overwriting existing event handlers. You can add many event handlers …

JavaScript Events Read More »

Object in JavaScript

JavaScript Object

JavaScript Object: JavaScript variables are containers for data values.So JavaScript Object are variables too, but they can contain many values. Think of an object as a list of values that are written as name:value pairs, with the names and the values separated by colons. Example: Creating Objects in JavaScript There are 3 ways to create …

JavaScript Object Read More »

Number in JavaScript

JavaScript Number

The JavaScript Number object represents numerical date, either integers or floating-point numbers. In general, you do not need to worry about Number objects because the browser automatically converts number literals to instances of the number class. You can direct assign a number to a variable also. For example: Number Constants Let’s see the list of …

JavaScript Number Read More »

boolean in JavaScript

JavaScript Boolean

JavaScript Boolean is an object that represents value in two states: true or false. You can create the Java Script Boolean object by Boolean() constructor as given below. The default value of Java Script Boolean object is false. Boolean Example: JavaScript Boolean Properties constructor : returns the reference of Boolean function that created Boolean object. prototype : enables you to add properties …

JavaScript Boolean Read More »

String in JavaScript

JavaScript String

The JavaScript String is an object that represents a sequence of characters. There are 2 ways to create string in JavaScript By string literal By string object (using new keyword) *) By string literal The string literal is created using double quotes. Let’s see the simple example of creating string literal. *) By string object (using new …

JavaScript String Read More »

array in javascript

JavaScript Array

JavaScript Array is an object that represents a collection of similar type of elements. Arrays store multiple values in a single variable. There are 3 ways to construct array in JavaScript By array literal And By creating instance of Array directly (using new keyword) And By using an Array constructor (using new keyword) i) JavaScript array …

JavaScript Array Read More »

math in javascript

JavaScript Math Property

The JavaScript Math Property allows you to perform mathematical tasks, and includes several properties. JavaScript Math Property Methods Let’s see the list of JavaScript Math methods with description. Math.sqrt(n) The JavaScript math.sqrt(n) method returns the square root of the given number. Math.random() The JavaScript math.random() method returns the random number between 0 to 1. Math.pow(m,n) …

JavaScript Math Property Read More »

Date in JavaScript

JavaScript Date

The JavaScript Date object enables us to work with dates. A date consists of a year, a month, a day, an hour, a minute, a second, and milliseconds. Using new Date(), create a new date object with the current date and time. Constructor You can use 4 variant of Date constructor to create date object. …

JavaScript Date Read More »