Articles on Trending Technologies

Technical articles with clear explanations and examples

How to concatenate several strings in JavaScript?

Ramu Prasad
Ramu Prasad
Updated on 15-Mar-2026 359 Views

JavaScript provides multiple methods to concatenate several strings. The most common approaches include using the + operator, template literals, Array.join(), and the concat() method. Method 1: Using the + Operator The simplest way to concatenate strings is using the + operator: let str1 = "John"; let str2 = "Amit"; let str3 = "Sachin"; ...

Read More

Fire a JavaScript function when a user finishes typing instead of on key up?

Krantik Chavan
Krantik Chavan
Updated on 15-Mar-2026 391 Views

To fire a JavaScript function when the user finishes typing instead of on every keystroke, use a debouncing technique with setTimeout and clearTimeout. This prevents the function from executing until the user stops typing for a specified delay. The Problem Using keyup or input events directly fires a function on every keystroke, which can cause performance issues or unwanted API calls. Debouncing ensures the function only runs after the user has finished typing. Example with jQuery ...

Read More

What are the best practices for function overloading in JavaScript?

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 340 Views

Function overloading occurs when a function performs different tasks based on the number or type of arguments passed to it. JavaScript doesn't support true function overloading like other languages, but we can implement similar behavior using best practices. Best Practices for Function Overloading When implementing function overloading in JavaScript, follow these key principles: Avoid type checking - Checking argument types slows down execution Don't check argument length - Use default parameters or options objects instead Use options objects - Pass configuration as the last parameter Leverage default parameters - Provide fallback values for missing arguments ...

Read More

How do I view events fired on an element in Chrome?

Fendadis John
Fendadis John
Updated on 15-Mar-2026 16K+ Views

To view events fired on an element in Google Chrome, you can use the Developer Tools to monitor and debug event listeners. This is essential for understanding how user interactions trigger JavaScript functions on your webpage. Method 1: Using Event Listener Breakpoints Open Google Chrome and press F12 to open Developer Tools. Navigate to the Sources tab in the Developer Tools panel. Chrome Developer Tools - Sources Tab Sources Elements Console ...

Read More

What are immediate functions in JavaScript?

varun
varun
Updated on 15-Mar-2026 467 Views

Immediate functions in JavaScript are functions that execute automatically as soon as they are defined. They are also known as Immediately Invoked Function Expressions (IIFEs). These functions help create private scope and avoid polluting the global namespace. Syntax (function() { // Code here executes immediately })(); // Alternative syntax (function() { // Code here executes immediately }()); Basic Example (function() { var message = "Hello from IIFE!"; console.log(message); })(); // This variable is not ...

Read More

How to preserve variables in a JavaScript closure function?

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

In this tutorial, we will look at the method to preserve variables in a JavaScript closure function. What is a closure function? A closure function gives access to the scope of an outer function from an inner function. It also allows private variables. Closure variables are stored in stack and heap. When a function is created, closure is also created. Closure remembers external things used in it. Closures are the primary mechanism for data privacy. One drawback is that the variables used are not garbage collected. Overuse of closure functions will damage the system due to redundant ...

Read More

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
Showing 19001–19010 of 61,297 articles
Advertisements