Javascript Articles

Page 502 of 534

Why are parenthesis used to wrap a JavaScript function call?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 5K+ Views

In JavaScript, functions wrapped with parentheses are called "Immediately Invoked Function Expressions" or "Self Executing Functions". The purpose of wrapping is to namespace and control the visibility of member functions. It wraps code inside a function scope and decreases clashing with other libraries. This is what we call Immediately Invoked Function Expression (IIFE) or Self Executing Anonymous Function. Syntax (function() { // code })(); As you can see above, the first pair of parentheses converts the code inside into an expression: (function(){...}) The second pair of parentheses ...

Read More

What is the difference between closure and nested functions in JavaScript?

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

In JavaScript, closures and nested functions are related but distinct concepts. A closure occurs when an inner function retains access to variables from its outer function's scope, even after the outer function has finished executing. Nested functions are simply functions defined inside other functions. JavaScript Closures A closure is formed when a function "closes over" variables from its lexical scope. The inner function remembers the environment in which it was created, not where it's called. JavaScript Closures JavaScript Closures Example ...

Read More

How to change font size in HTML?

Syed Javed
Syed Javed
Updated on 15-Mar-2026 134K+ Views

To change the font size in HTML, use the CSS font-size property. You can apply it using the style attribute for inline styles, internal CSS with the tag, or external CSS files. HTML5 does not support the deprecated tag, so CSS is the modern approach. Keep in mind that inline styles using the style attribute override any global styles set in tags or external stylesheets. Using Inline Styles The simplest method is using the style attribute directly on HTML elements: ...

Read More

How to create a link to send email with a subject in HTML?

Ayyan
Ayyan
Updated on 15-Mar-2026 21K+ Views

To create a link that opens the user's email client with a pre-filled subject line, use the tag with a mailto: URL in the href attribute. Syntax Link Text Key Points Use mailto: followed by the recipient's email address Add ?Subject= to include a subject line Replace spaces in the subject with %20 (URL encoding) The link will open the user's default email client Basic Example ...

Read More

Understanding function scope and context in JavaScript?

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

In this tutorial, let us discuss the function scope and context in JavaScript. Functions are the building blocks of JavaScript. Understanding scope and context is crucial for writing maintainable code and avoiding common pitfalls. Scope Scope determines where variables can be accessed in your code. JavaScript has four types of scope: Global Scope Variables declared outside any function have global scope and are accessible throughout the program. Variables declared with var become properties of the window object, while let and const don't. Global Scope Example ...

Read More

How to arguments object with Rest, default, and destructured parameters in JavaScript?

Abhinaya
Abhinaya
Updated on 15-Mar-2026 217 Views

JavaScript ES6 introduced powerful parameter features that modernize how functions handle arguments. This article explores default parameters, rest parameters, and destructuring assignment - three essential concepts for writing cleaner, more flexible JavaScript functions. Default Parameters Default parameters allow you to initialize function parameters with default values when no value or undefined is passed. This eliminates the need for manual parameter checking and makes functions more robust. Syntax function functionName(param1, param2 = defaultValue) { // function body } Example ...

Read More

How to concatenate multiple string variables in JavaScript?

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

In this tutorial, we will learn to concatenate multiple string variables in JavaScript. String concatenation is the process of merging two or more strings into a single string. This operation is fundamental in JavaScript development and is commonly used for creating dynamic content, building messages, and manipulating text data. String concatenation is particularly useful when you need to insert substrings into existing strings or build complex strings from multiple variables. For example, when developing applications, you might need to combine user input with predefined text or merge data from different sources. There are three main methods to concatenate ...

Read More

How to create a dialog with "yes" and "no" options in JavaScript?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 3K+ Views

JavaScript's built-in confirm() dialog only provides "OK" and "Cancel" buttons. To create a custom dialog with "Yes" and "No" options, you need to build a custom modal using HTML, CSS, and JavaScript. Built-in confirm() Limitation The standard confirm() function cannot be customized to show "Yes/No" buttons: // Built-in confirm() only shows OK/Cancel let result = confirm("Do you want to continue?"); console.log(result ? "User clicked OK" : "User clicked Cancel"); Custom Yes/No Dialog Solution Here's a complete custom dialog implementation using jQuery: ...

Read More

How to change button label in alert box using JavaScript?

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

In this tutorial, we will learn to change the button label in the alert box using JavaScript. The default JavaScript alert box contains a simple message and an "OK" button, but we cannot customize its appearance or button text directly. Since the native alert() method doesn't allow customization, we need to create custom alert boxes using HTML, CSS, and JavaScript. This approach gives us full control over styling and button labels. The Problem with Default Alert Boxes The default alert() method has limitations: ...

Read More

How to call a JavaScript function from C++?

Akansha Kumari
Akansha Kumari
Updated on 15-Mar-2026 1K+ Views

Calling a JavaScript function directly from C++ depends on the environment and the system; for this, make sure you have embedded a JavaScript engine or integrated C++ with JavaScript. In this article, we will be using Emscripten (C++ to JavaScript in WebAssembly) to call a JavaScript function from C++. For this, you have to compile the C++ program to WebAssembly using Emscripten and then call JavaScript functions from C++. So, first, create the C++ file with the header . How Emscripten Works Emscripten compiles C++ code to WebAssembly, which runs in browsers. The compiled WebAssembly module can ...

Read More
Showing 5011–5020 of 5,340 articles
« Prev 1 500 501 502 503 504 534 Next »
Advertisements