Articles on Trending Technologies

Technical articles with clear explanations and examples

What is the use of JavaScript eval function?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 441 Views

The JavaScript eval() function executes a string as JavaScript code. While powerful, it's generally discouraged due to performance and security concerns. Syntax eval(string) Parameters string: A string representing a JavaScript expression, statement, or sequence of statements. Return Value Returns the completion value of evaluating the given code. If the completion value is empty, undefined is returned. Basic Example var a = 30; var b = 12; ...

Read More

What is the (function() { } )() construct in JavaScript?

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

The (function() { } )() construct is an immediately invoked function expression (IIFE). It is a function that executes immediately upon creation, without needing to be called separately. Syntax (function() { // code })(); The first pair of parentheses converts the function declaration into an expression: (function(){...}) The second pair of parentheses immediately invokes that function expression. Basic Example (function() { console.log("IIFE executed immediately!"); })(); console.log("This runs after IIFE"); IIFE executed immediately! This runs after IIFE ...

Read More

How to check if a JavaScript function is defined?

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

In this tutorial, we will learn to check whether a JavaScript function is defined before calling it. If you call an undefined function, JavaScript throws a ReferenceError with the message "function is not defined." To avoid this error, you can check whether the function exists before calling it. We'll explore three different approaches to accomplish this. Using the typeof Operator The typeof operator returns the data type of a variable or function. When used with a function name, it returns 'function' if the function is defined, or 'undefined' if it's not. Syntax let isFunction ...

Read More

What is "function*" in JavaScript?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 348 Views

The function* declaration defines a generator function that returns a Generator object. Unlike regular functions, generators can pause execution with yield and resume later, making them powerful for controlling program flow and creating iterators. Syntax Generator functions can be declared with function* in three equivalent ways: function* myFunction() {} // or function *myFunction() {} // or function*myFunction() {} How Generator Functions Work When called, a generator function doesn't execute immediately. Instead, it returns a generator object with methods like next() to control execution step by step. Basic Example ...

Read More

How to find JavaScript function definition in Chrome?

Abhishek
Abhishek
Updated on 15-Mar-2026 7K+ Views

When developing or debugging web applications, finding JavaScript function definitions in Chrome is essential. Chrome provides multiple methods to locate functions quickly and efficiently. This tutorial covers three primary methods for finding JavaScript functions in Google Chrome: Using Developer Tools Sources Panel Using Inspect Element Using View Page Source Using Developer Tools Sources Panel The Developer Tools Sources panel is the most powerful method for finding and debugging JavaScript functions. Steps to Use Developer Tools Step 1: Open Developer Tools ...

Read More

What is the purpose of wrapping whole JavaScript files in anonymous functions?

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

The purpose of wrapping JavaScript files in anonymous functions is to create a namespace and control the visibility of member functions. It wraps the 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 Here's the basic IIFE syntax: (function() { // code })(); As you can see above, the first pair of parentheses converts the code inside into an expression. The second pair of parentheses immediately calls the function that resulted from the ...

Read More

How do you find out the caller function in JavaScript?

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

In this tutorial, we will learn to find out the caller function in JavaScript. The function is the reusable code, and users can call it from anywhere. But sometimes, they need to know who is the caller function to perform some operation. For example, suppose that we can call any single function from another 2 to 3 functions, and we need to perform some operation according to the caller function. Users can understand this scenario by the below code example. function func3() { if (caller is func2()) { ...

Read More

How do I declare a namespace in JavaScript?

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

A namespace is a programming concept that gives identifiers (names of types, functions, variables, etc.) scope to avoid name conflicts. JavaScript doesn't have built-in namespace support, but we can simulate namespaces using objects to organize code and prevent variable name collisions. In modern web applications that use multiple libraries and components, namespaces help avoid confusion and conflicts in code. This tutorial covers how to implement namespaces in JavaScript using different approaches. Object Literal Notation The most common way to create namespaces in JavaScript is using Object Literal Notation. This approach creates a global object that contains all ...

Read More

What does the exclamation mark do before the function in JavaScript?

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

The exclamation mark (!) before a function in JavaScript is used to create an Immediately Invoked Function Expression (IIFE). It transforms a function declaration into an expression that can be executed immediately. How It Works The ! operator has lower precedence than the parentheses (), so the function executes first, then the ! operator applies to its return value: !function() { console.log("IIFE executed!"); }(); IIFE executed! Return Value Behavior Since functions return undefined by default, the ! operator converts this to true: let result1 ...

Read More

How to add number of days to JavaScript Date?

Saurabh Jaiswal
Saurabh Jaiswal
Updated on 15-Mar-2026 19K+ Views

In this tutorial, we will learn how to add a number of days to a JavaScript Date object. Here we will discuss two methods which are following. Using the setDate( ) Method Using the getTime() Method Using the setDate( ) Method JavaScript date setDate() method sets the day of the month for a specified date according to local time. Syntax Date.setDate(dayValue) Here dayValue is an integer from 1 to 31, representing the day of the month. Approach To add a number of ...

Read More
Showing 19101–19110 of 61,297 articles
Advertisements