Front End Technology Articles

Page 343 of 652

What is onsubmit event in JavaScript?

V Jyothi
V Jyothi
Updated on 15-Mar-2026 4K+ Views

The onsubmit event is an event that occurs when you try to submit a form. You can put your form validation against this event type. The following example shows how to use onsubmit. Here we are calling a validate() function before submitting a form data to the web server. If validate() function returns true, the form will be submitted, otherwise, it'll not submit the data. Syntax // form elements // Or using JavaScript form.onsubmit = function(event) { // validation logic return true; ...

Read More

What are Complex Data types in JavaScript?

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

In this tutorial, we will learn about complex data types in JavaScript. JavaScript has multiple built-in data types to store data in different formats. The data types of JavaScript can be divided into two groups: primitive data types and non-primitive data types. Number, String, Boolean, Undefined and Null are primitive data types, whereas Array and Object are non-primitive data types. The typeof operator is used to identify data types. The primitive data types are simple and easy to use. In contrast, the non-primitive data types (Array and Object) are relatively more complex than primitive data types, so the ...

Read More

How to invoke a JavaScript Function with 'new' Function Constructor?

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

In this tutorial, we will learn how to invoke a JavaScript Function with the 'new' Function Constructor. Functions are a set of reusable codes that perform a specific task and may return a value. In JavaScript, functions are defined by the keyword function. A function may not have any parameters and may also not have any return statement. In JavaScript, we also have functions with no function names, called anonymous functions. Using the 'new' Function Constructor The Function constructor makes a new Function object. By using the constructor, we can create a function dynamically. It takes parameters, ...

Read More

What is the difference between "strict" and "non-strict" modes of JavaScript?

Abhinanda Shri
Abhinanda Shri
Updated on 15-Mar-2026 1K+ Views

The "use strict" is a directive introduced in JavaScript 1.8.5 that enables strict mode execution. In strict mode, JavaScript enforces stricter parsing and error handling, while non-strict mode (the default) is more permissive and allows certain problematic practices. Enabling Strict Mode To enable strict mode, add "use strict"; at the beginning of your script or function. For global scope, place it at the top of the script file. Check the console for errors (F12) ...

Read More

How to return a value from a JavaScript function?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 3K+ Views

To return a value from a JavaScript function, use the return statement. The return statement sends a value back to the code that called the function and immediately exits the function. Syntax function functionName() { // function body return value; } Example: Basic Return Statement function concatenate(name, age) { var val = name + age; ...

Read More

How does JavaScript 'return' statement work?

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

In this article, we will learn how to work with a return statement in JavaScript. A specific value from the function is returned to the function caller using the return statement. Whenever the return statement is run, the function will stop. The code that follows the return statement won't be available, due to which it is the last statement in a function. Using the return statement, we may return object types, including functions, objects, arrays, and primitive values like Boolean, integer, and string. By using the return statement, we can also return many items. To return several values ...

Read More

How to find the min/max element of an Array in JavaScript?

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

In JavaScript, finding the minimum and maximum elements of an array is a common task. The minimum element is the smallest value in the array, while the maximum is the largest. This tutorial covers the most effective approaches to accomplish this. There are two main approaches to find min/max elements: Manual traversal using loops Using Math.min() and Math.max() methods Method 1: Manual Array Traversal This approach involves iterating through the entire array and comparing each element to keep track of the minimum and maximum values. It ...

Read More

How to create a two dimensional array in JavaScript?

Nikitha N
Nikitha N
Updated on 15-Mar-2026 813 Views

A two-dimensional array has more than one dimension, such as myarray[0][0] for element one, myarray[0][1] for element two, etc. JavaScript doesn't have true 2D arrays, but you can create arrays of arrays to achieve the same functionality. Method 1: Using Array Constructor with Loop This method creates an empty 2D array and fills it row by row: var myarray = new Array(3); for (i = 0; ...

Read More

How to remove an item from JavaScript array by value?

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

In this tutorial, we will learn to remove an item from a JavaScript array by value. An array is a data structure that can store a collection of elements. JavaScript provides several methods to manipulate arrays, including removing specific elements by their value rather than their index position. Following are the main methods to remove an item from an array by value: The Array filter() Method The Array splice() Method with indexOf() Using the Array filter() Method The filter() method creates a new array containing elements that ...

Read More

What does "use strict" do in JavaScript, and what is the reasoning behind it?

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

In this tutorial, we will learn what "use strict" does in JavaScript and why it's important for writing safer code. The "use strict" directive enables strict mode in JavaScript, which was introduced in ECMAScript 5 (ES5). It enforces stricter parsing and error handling, helping developers catch common mistakes and write more secure code. What is Strict Mode? Strict mode changes both syntax and runtime behavior. It eliminates some JavaScript silent errors by changing them into throw errors, fixes mistakes that make it difficult for JavaScript engines to perform optimizations, and prohibits some syntax likely to be defined ...

Read More
Showing 3421–3430 of 6,519 articles
« Prev 1 341 342 343 344 345 652 Next »
Advertisements