Found 10483 Articles for Web Development

Named arguments in JavaScript.

AmitDiwan
Updated on 17-Jul-2020 08:53:14

235 Views

Following is the code for using named arguments in JavaScript functions −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample, .result {       font-size: 18px;       font-weight: 500;       color: red;    }    .result {       color: rebeccapurple;    } Named arguments in JavaScript functions CLICK HERE Click on the above button to call a function and pass above object to it as argument    let sampleEle ... Read More

JavaScript program to get a variable to count up/down on keyboard press.

Disha Verma
Updated on 13-Mar-2025 13:06:03

520 Views

When working with JavaScript, handling keyboard events and creating a program that gets a variable to count up/down on keyboard press can be an essential skill. Keyboard events such as keydown and keyup in JavaScript are actions that occur when a user interacts with the keyboard. This article explains how to create a JavaScript program that increments or decrements a variable based on specific keyboard key presses. This feature can be helpful in interactive websites, like games or tools that check user input. Table of Content You can create a JavaScript program to get a variable to count up ... Read More

Can we have a return statement in a JavaScript switch statement?

AmitDiwan
Updated on 17-Jul-2020 08:47:22

21K+ Views

The JavaScript switch statement can contain return statements if it is present inside a function. The function will return the value in the switch statement and the code after the switch statement will not be executed.Following is the code to have return statements in JavaScript switch statement −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;    } Return statement in JavaScript switch Enter day 1-7 CHECK ... Read More

How to group array of objects by Id in JavaScript?

AmitDiwan
Updated on 17-Jul-2020 08:43:33

2K+ Views

Following is the code to group array of objects by id in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: rebeccapurple;    } group the array of objects by Id in JavaScript { name: 'Rohan', age: 18 }, { name: 'Mohan', age: 20 }, { name: 'Shawn', age: 18 }, { name: 'Michael', age: 18 }, { name: 'David', age: 20 } ... Read More

How to disable mouse event on certain elements using JavaScript?

AmitDiwan
Updated on 17-Jul-2020 08:38:57

4K+ Views

Following is the code for disabling mouse event on certain elements using JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: rebeccapurple;    }    .size {       font-size: 30px;    } Disable Mouse events using JavaScript This is some text inside a div DISABLE ENABLE Click on the above button to enable or disable mouse events    let resEle ... Read More

JavaScript program to access browsing history

AmitDiwan
Updated on 23-Dec-2024 11:17:25

680 Views

In this article, we will learn to access browsing history using Javascript. In web development, accessing a user’s browsing history can improve user experience and provide personalized content. However, due to privacy concerns and security reasons, modern web browsers limit the amount of browsing history accessible via JavaScript.  What is Browsing History? Browsing history refers to the list of web pages that a user has visited over a while. Browsers typically store this data locally, allowing users to navigate back and forth through the pages they’ve visited. The window.history Object In JavaScript, the window.history object allows interaction with the browser’s ... Read More

Explain Enumerated Types in JavaScript.

AmitDiwan
Updated on 17-Jul-2020 08:23:14

158 Views

JavaScript doesn’t support Enums out of the box. The only way to have enums in javaScript is to implement them using objects.Following is the code showing enumerated types in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: rebeccapurple;    } Enumerated Types in JavaScript CLICK HERE Click on the above button to get the color values    let resEle = document.querySelector(".result");   ... Read More

How to embed JavaScript in HTML file?

AmitDiwan
Updated on 17-Jul-2020 08:20:18

523 Views

Following is the code to embed JavaScript in html file −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: rebeccapurple;    } Embed javascript in html file    let resEle = document.querySelector(".result");    resEle.innerHTML += "Inline javaScript loaded" + ""; script.jsresEle.innerHTML += 'External JavaScript loaded ';OutputThe above code will produce the following output −

Explain shorthand functions in JavaScript?

AmitDiwan
Updated on 17-Jul-2020 08:16:46

1K+ Views

The arrow functions also known as shorthand functions were introduced in ES2015 and allows us to write function in a shorter way. They don’t have their own binding to this and get the this from the surrounding context.Following is the code showing shorthand functions in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: rebeccapurple;    } Shorthand function in JavaScript CLICK HERE Click ... Read More

How to create a URL object using JavaScript?

AmitDiwan
Updated on 17-Jul-2020 08:12:47

507 Views

Following is the code to create a URL object using JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: rebeccapurple;    } Url object in JavaScript CLICK HERE Click on the above button to create and display a url object    let resEle = document.querySelector(".result");    let url = new URL("https://google.com/image=23&size=440px");    document.querySelector(".Btn").addEventListener("click", () => {       resEle.innerHTML += "url protocol = " + url.protocol + "";       resEle.innerHTML += "url host = " + url.host + "";       resEle.innerHTML += "url.pathname = " + url.pathname + "";    }); OutputThe above code will produce the following output −On clicking the ‘CLICK HERE’ button −

Advertisements