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
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to call a parent window function from an iframe using JavaScript?
When working with iframes, you often need to call functions defined in the parent window from within the iframe. JavaScript provides several methods to achieve this cross-frame communication. Using window.parent The most common approach is using window.parent to reference the parent window: Parent Window Parent Window function displayMessage(message) { ...
Read MoreHow to use unlimited arguments in a JavaScript function?
In JavaScript, functions typically accept a fixed number of parameters, but there are several ways to handle an unlimited number of arguments. This tutorial explores three methods to pass and process multiple arguments in JavaScript functions. Using ES5 Arguments Object The arguments object is available in all non-arrow functions and contains all arguments passed to the function, regardless of how many parameters are defined. Syntax function functionName(param1, param2) { var actualParams = functionName.length; // Number of defined parameters var totalArgs = arguments.length; ...
Read MoreHow can I declare optional function parameters in JavaScript?
This tutorial will teach us how to declare optional function parameters in JavaScript. While declaring the function, we pass some variables to the function definition to use it inside the function block, called function parameters. The function parameters can also be optional, which gives us the independence to pass function arguments when we call the function. Here, Arguments are the values we pass while calling the function, and parameters are the variables we pass in the function definition. What Are Optional Parameters? The optional parameter word means that you don't need to pass that parameter every time ...
Read MoreWhat is Multiplication Assignment Operator (*=) in JavaScript?
The multiplication assignment operator (*=) in JavaScript provides a shorthand way to multiply a variable by a value and assign the result back to the variable. Instead of writing a = a * b, you can simply use a *= b. Syntax operand1 *= operand2 // equivalent to: operand1 = operand1 * operand2 The multiplication assignment operator is a binary operator that multiplies the left operand by the right operand and stores the result in the left operand. Example 1: Basic Usage with Numbers Here's how the multiplication assignment operator works with numeric ...
Read MoreHow to delay a JavaScript function call using JavaScript?
In this tutorial, we are going to learn how can we delay a function in JavaScript. Whenever we want to call a function after a specified amount of time than we use the delay function in JavaScript. To provide delay in JavaScript function we use a global window object named as setTimeout(). This function allows us to provide a specific delay before executing a function. The setTimeout() method mainly requires two arguments: the function which we need to execute with some delay and the time (in milliseconds) for which we want to delay the function. Syntax ...
Read MoreHow to use associative array/hashing in JavaScript?
We use Object and Map classes to mimic the behavior of associative array/hashing in JavaScript. JavaScript doesn't provide an associative array built-in. The closest similar behavior we get is from the Map class in JavaScript. Let us look at them one by one. Object Class in JavaScript The object class allows us to create objects with name-value pairs. This is similar to hashing as the object knows which property is associated with what value. Syntax const obj = { name : "Abhishek", age : 22 } var name ...
Read MoreHow to encode a URL using JavaScript function?
As we know, a URL is a web address. What is URL encoding and why do we need to encode a URL? The process of turning a string into an accurate URL format is known as URL encoding. A valid URL format only uses "alpha | digit | safe | extra | escape" characters. Only a limited selection of the normal 128 ASCII characters is permitted in URLs. Reserved characters that are not part of this set must be encoded. URL encoding increases the reliability and security of URLs. Each character that needs to be URL-encoded is encoded ...
Read MoreHow to decode a URL using JavaScript function?
In this tutorial, we will learn how to decode a URL using JavaScript. URL is an abbreviation for Uniform Resource Locator. A URL is the address of a certain Web site. Each valid URL, in principle, links to a different resource. These resources include an HTML page, a CSS document, a picture, etc. URL encoding refers to replacing certain characters in a URL with one or more character triplets composed of the percent character "%" followed by two hexadecimal numbers. The triplet's two hexadecimal digits represent the numeric value of the replacement character. URL encoding's reverse process is ...
Read MoreHow to add a number of months to a date using JavaScript?
To add a number of months to a date in JavaScript, you can use the setMonth() method combined with getMonth(). This approach automatically handles year transitions and varying month lengths. Basic Syntax date.setMonth(date.getMonth() + numberOfMonths); Example: Adding Months to Current Date var currentDate = new Date(); var monthsToAdd = 3; document.write("Original Date: ...
Read MoreHow to parse JSON object in JavaScript?
JSON (JavaScript Object Notation) is a lightweight data format commonly used for data exchange. JavaScript provides the built-in JSON.parse() method to convert JSON strings into JavaScript objects. Syntax JSON.parse(text, reviver) Parameters text - The JSON string to parse reviver (optional) - A function that transforms the results Basic JSON Parsing Example // Simple JSON string let jsonString = '{"name": "John", "age": 30, "city": "New ...
Read More