Front End Technology Articles

Page 336 of 652

How to create JavaScript alert with 3 buttons (Yes, No and Cancel)?

Prabhas
Prabhas
Updated on 15-Mar-2026 4K+ Views

The standard JavaScript alert box won't work if you want to customize it. For that, we have a custom alert box, which we're creating using jQuery and styled with CSS. Understanding the Problem JavaScript's built-in alert() and confirm() functions are limited - they only provide basic "OK" or "OK/Cancel" options. To create a custom dialog with Yes, No, and Cancel buttons, we need to build our own solution using HTML, CSS, and JavaScript. Complete Example Here's a complete implementation of a custom alert with three buttons: ...

Read More

How to print object array in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 21K+ Views

In this tutorial, we will learn how to print object arrays in JavaScript. An array of objects is a collection that stores multiple objects with similar structure in a single variable. Each object can contain multiple properties, making it useful for storing complex data like user information, product details, or any structured data. Let's explore different methods to print arrays of objects in JavaScript. Using JSON.stringify() Method The JSON.stringify() method converts JavaScript objects into JSON strings, making it perfect for displaying arrays of objects in a readable format. Syntax JSON.stringify(value, replacer, space) ...

Read More

Why in JavaScript, "if ('0' == false)" is equal to false whereas it gives true in "if(0)" statement?

mkotla
mkotla
Updated on 15-Mar-2026 2K+ Views

JavaScript's comparison behavior can be confusing when mixing different data types. Let's examine why '0' == false returns true while if(0) evaluates to false. Understanding '0' == false When using the loose equality operator ==, JavaScript performs type coercion following specific rules: console.log('0' == false); // true console.log(typeof '0'); // "string" console.log(typeof false); // "boolean" true string boolean The comparison follows this rule: If Type(y) is Boolean, return the result of the comparison x == ToNumber(y) Here's what happens step by step: ...

Read More

How to print a triangle formed of '#' using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 4K+ Views

In this tutorial, we will learn to print a triangle formed of '#' using JavaScript. You need to use nested loops to print a triangle formed of '#' in JavaScript. The outer loop controls the number of rows, while the inner loop controls how many '#' symbols to print in each row. Nested loops are loops that contain another loop inside them. We'll explore two approaches using different types of loops in JavaScript: for loop while loop Using for Loop to Print a Triangle The for loop ...

Read More

How exactly does work?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 326 Views

The defer attribute tells the browser to download the script while parsing HTML but delay execution until the DOM is fully built. It only works with external scripts and maintains execution order. How defer Works HTML Parsing Script Download Script Execution 1. HTML parsing continues while script downloads 2. Script waits until DOM is complete 3. Scripts execute in document order ...

Read More

How to include inline JavaScript inside an HTML page?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 9K+ Views

In this tutorial, we will learn how to include inline JavaScript inside an HTML page. Inline JavaScript allows you to write JavaScript code directly within HTML event attributes, making it useful for simple interactions without external script files. Using Inline JavaScript to Show an Alert Message One of the simplest ways to understand inline JavaScript is by using the alert method. The alert method opens a pop-up window containing a message. Inline JavaScript code is written within event attributes and executes when that event is triggered. Syntax // inline JavaScript within the onclick attribute of ...

Read More

How to preselect a list item using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 320 Views

In this tutorial, we will learn how to preselect a select list item using JavaScript. This is useful when you want to set a default selection dynamically based on user preferences or application state. The HTML element creates dropdown menus where users can choose from multiple options. Each element represents a selectable choice. You can preselect options either by adding the selected attribute in HTML or programmatically using JavaScript. Understanding Select Elements A select element consists of: id attribute - Associates with labels for accessibility name attribute - ...

Read More

How to use JavaScript to redirect an HTML page?

Rishi Raj
Rishi Raj
Updated on 15-Mar-2026 2K+ Views

You might have encountered a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection. JavaScript provides several methods to redirect users from one page to another. This is commonly used for routing users after form submissions, authentication, or when content has moved to a new location. Methods for Page Redirection There are three main ways to redirect pages using JavaScript: Using window.location.href The most common method assigns a new URL to window.location.href: ...

Read More

How to fix problems related to the JavaScript Void 0 Error?

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 2K+ Views

The JavaScript "void(0)" error typically occurs when JavaScript is disabled in the browser or when there are issues with JavaScript execution. This error commonly appears as "javascript:void(0)" in links or when scripts fail to run properly. What is JavaScript void(0)? The void operator in JavaScript evaluates an expression and returns undefined. When used as void(0) or void 0, it simply returns undefined without executing any meaningful operation. console.log(void(0)); // undefined console.log(void 0); // undefined console.log(void(1 + 2)); ...

Read More

How can I force clients to refresh JavaScript files?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 12K+ Views

When you update JavaScript files on your server, browsers may still load the old cached version instead of your new code. This tutorial shows you how to force browsers to reload updated JavaScript files automatically. The problem occurs because browsers cache JavaScript files locally for faster loading. When you deploy new code, browsers continue serving the old cached files instead of fetching updated ones from the server. This causes users to see outdated functionality even after you've deployed new features or fixes. Understanding Browser Caching When users visit your application, browsers store CSS and JavaScript files in ...

Read More
Showing 3351–3360 of 6,519 articles
« Prev 1 334 335 336 337 338 652 Next »
Advertisements