Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Front End Technology Articles
Page 413 of 652
How to enable a strict mode in javascript?
In JavaScript, there are two different programming paradigms. The sloppy mode, sometimes referred to as the simple mode, is activated by default. We don't have to write the code strictly according to guidelines in this manner. On the other side, there is also the strict mode. This setting allows the environment to have some rigid constraints. Strict mode has different semantics than regular code and is not a subset of sloppy mode. This article will explain how to enable strict mode in JavaScript and will also go over some of the features of "Strict" Mode. Syntax Different scopes ...
Read MoreHow to call JavaScript function in an alert box?
To call a JavaScript function in an alert box, you can use the alert() function, a built-in function in JavaScript that displays an alert dialog with a specified message. An alert box is a simple dialog box that displays a message to the user and provides an OK button. It is a built-in function in JavaScript that is often used for debugging or displaying simple notifications to the user. Here's an example of how to use the alert() function in JavaScript: alert("Hello, World!"); ...
Read MoreExplain focus events in JavaScript
Focus events in JavaScript are triggered when HTML elements gain or lose focus on a web page. These events are essential for creating interactive user interfaces and handling form interactions effectively. Focus events occur when users interact with focusable elements like input fields, buttons, or links through clicking, tabbing, or keyboard navigation. Understanding these events helps create responsive and accessible web applications. Types of Focus Events JavaScript provides four main focus events: focus − Triggered when an element gains focus. Does not bubble up the DOM tree. blur − ...
Read MorePreventDefault( ) vs Return false in JavaScript?
In JavaScript, when handling events, you often need to prevent the default browser behavior. The two common approaches are preventDefault() and return false, but they work differently. The preventDefault() method stops only the default action, while return false stops both the default action and event propagation. Key Differences preventDefault() return false Method available on event objects JavaScript statement that can be used anywhere Stops only the default behavior Stops default behavior AND event propagation Allows event to continue bubbling up Stops event bubbling and function execution ...
Read MoreLocation protocol Property in JavaScript
The location.protocol property in JavaScript returns the protocol scheme of the current webpage's URL, including the colon (:). It's a read-only property that helps identify whether a page is served over HTTP, HTTPS, or other protocols. Syntax location.protocol Return Value Returns a string representing the protocol scheme, including the trailing colon. For example: "https:", "http:", "file:", etc. Common Protocol Values http: − Hypertext Transfer Protocol (unsecured) https: − Hypertext Transfer Protocol Secure (secured with SSL/TLS) file: − Local file system access ...
Read MoreCreating auto-resize text area using JavaScript
In this post, we are going to learn how to set up an auto-resize text area in JavaScript. This text area will be able to change its height automatically depending on the content within it. Auto-resize text in JavaScript is a helpful feature that can be used to edit multiple lines of text. The text can automatically change its height depending on the content inside it. The default behavior of textarea doesn't allow this, but we can create it by using the input event listener over it. Let's understand how to adjust the height of the text area element ...
Read MoreHow to toggle a boolean using JavaScript?
In this tutorial, we will learn how to toggle a boolean value in JavaScript. In addition to this, we will also learn how we can use it for various web application features that require toggling a certain piece of state or value. Toggling a boolean in JavaScript entails altering its value from true to false or vice versa. Toggling booleans can be helpful in a variety of situations, such as changing a boolean value to initiate an action or to toggle between states or the visibility of an element. Toggling can be implemented using different methods like the ...
Read MoreProgram to check/uncheck checkboxes using JavaScript
We will learn how to check or uncheck checkboxes in JavaScript in this article, and how we can use it to allow users to make multiple selections on web pages. Checkboxes are one of the most used HTML elements in forms and user interfaces that allow users to pick multiple options. In JavaScript, we can dynamically check or uncheck checkboxes based on certain conditions or user interactions. Let's look at some examples to understand the concept better: Basic Check All/Uncheck All In this example, we will: Create 3 different checkboxes with ...
Read MoreHow to add delay in a loop in JavaScript?
Loops are used in JavaScript to repeat actions or iterate over data. Adding delays between iterations helps control execution speed, create animations, or prevent overwhelming the browser. This article demonstrates how to add delays in JavaScript loops using different techniques. Let's explore practical examples to understand the concept better. Using setTimeout() with Recursive Functions The setTimeout() approach uses recursion to process each array element with a delay: function delayedLoop() { var items = [1, 2, 3, 4, 5]; var delay = 1000; // 1 second ...
Read MoreHow to convert Array to Set in JavaScript?
This tutorial will teach you how to eliminate duplicate values from an array by converting it to a Set in JavaScript. Sets are collections that store only unique values. When you need to remove duplicates from an array or leverage the unique properties of Sets, converting an array to a Set is the most efficient approach. Using the Set Constructor (Recommended) The Set constructor accepts any iterable object, including arrays, and automatically removes duplicate values. Convert Array to Set - Using Set Constructor ...
Read More