The JavaScript location protocol property returns the protocol used by the current URL.Following is the code for Location protocol Property in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample{ font-size: 18px; font-weight: 500; color: red; } Location protocol Property CLICK HERE Click on the above button to get the location protocol let sampleEle = document.querySelector(".sample"); document.querySelector(".Btn").addEventListener("click", () => { sampleEle.innerHTML = 'The protocol used by the website = ' + location.protocol; }); OutputOn clicking the “CLICK HERE” button −
The JavaScript Let keyword introduced in 2015 allows us to define block scoped variables.Following is the code for declaring variable using Let keyword in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample{ font-size: 18px; font-weight: 500; color: red; } JavaScript Let CLICK HERE Click on the above button to access the varible let sampleEle = document.querySelector(".sample"); document.querySelector(".Btn").addEventListener("click", () => { ... Read More
The length property in JavaScript returns the size of the object. Following is the code for the length of string and array objects −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample, .result { font-size: 18px; font-weight: 500; color: red; } JavaScript length property CLICK HERE Click on the above button to find the length of the array let sampleEle = document.querySelector(".sample"); let resultEle = document.querySelector(".result"); let arr = [1, 2, "A", "B", "D"]; sampleEle.innerHTML = arr; document.querySelector(".Btn").addEventListener("click", () => { resultEle.innerHTML += "The array length is = " + arr.length; }); OutputOn clicking the ‘CLICK HERE’ button −
The lastIndex property in JavaScript returns the index position when a match occurs and the next match then resumes from that position only. The lastIndex property works only if the ‘g’ modifier is set.Following is the code for the lastIndex property in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample, .result { font-size: 18px; font-weight: 500; color: red; } JavaScript lastIndex Property The king bought an expensive ring. ... Read More
To know the value of GET parameters from URL in JavaScript, the code is as follows −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; color: red; } GET parameters from URL https://www.google.com?imageSize=440&color=blue CLICK HERE Click on the above button to get the imageSize and color value from the above URL let sampleEle = document.querySelector(".sample"); let resultEle = document.querySelector(".result"); ... Read More
The JSON parse() method is used for parsing a JSON string and then creating a JavaScript object from it.Following is the code for JSON parse() method −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; color: red; } JSON parse() Method {"name":"Rohan", "sports":["Cricket", "Football"], "country":"India"} CLICK HERE Click on the above button to parse the above JSON string let ... Read More
To generate HTML using JSON data, the code is as follows −Note − JSONPlaceholder is a fake Online REST API for Testing and PrototypingExample Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; color: red; } JSON arrays EMPLOYEE NAME CLICK HERE Click on the above button to fill the employee table let sampleEle = document.querySelector(".employee"); document.querySelector(".Btn").addEventListener("click", () => { fetch("https://jsonplaceholder.typicode.com/users") .then((response) => response.json()) .then((result) => { result.forEach((element) => { sampleEle.innerHTML += "" + element.name; }); }); }); OutputOn clicking the ‘CLICK HERE’ button −
Arrays in JSON are similar to Arrays in JavaScript. JavaScript JSON arrays looks like this −let obj = { name:'Rohan', sports : ['cricket','Football','volleyball','hockey'] }Following is the code for JSON arrays in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; } JSON arrays CLICK HERE Click on the above button to access JSON array let sampleEle = document.querySelector(".sample"); let obj = { name:'Rohan', sports : ['cricket','Football','volleyball','hockey'] } document.querySelector(".Btn").addEventListener("click", () => { obj.sports.forEach(item=>{ sampleEle.innerHTML += item + ''; }) }); OutputOn clicking the ‘CLICK HERE’ button −
The JavaScript infinity property displays infinity if the upper limit of the floating-point number is exceed and − infinity if the lower limit of the floating point number has has been exceeded.Following is the code for JavaScript infinity property −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .num { font-size: 18px; font-weight: 500; } JavaScript Infinity property 1.797693134862315E+10308 -1.797693134862315E+10308 CLICK HERE Click on the above button to add and subtract the above floating ... Read More
The JavaScript Immediately Invoked Function Expressions (IIFE) is a JavaScript function that executes immediately after it has been defined so there is no need to manually invoke IIFE.Following is the code for Immediately Invoked Function Expressions (IIFE) in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; } JavaScript Immediately Invoked Function Expressions (IIFE) let sampleEle = document.querySelector(".sample"); (function () { sampleEle.innerHTML ="This code is invoked immediately as soon as it is defined"; })(); Output
 
 Data Structure
 Data Structure Networking
 Networking RDBMS
 RDBMS Operating System
 Operating System Java
 Java MS Excel
 MS Excel iOS
 iOS HTML
 HTML CSS
 CSS Android
 Android Python
 Python C Programming
 C Programming C++
 C++ C#
 C# MongoDB
 MongoDB MySQL
 MySQL Javascript
 Javascript PHP
 PHP