Front End Technology Articles

Page 386 of 652

How to find the name and the target of a form in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 1K+ Views

In JavaScript, you can access the name and target attributes of HTML forms using DOM properties. These attributes help identify forms and control where form submissions open. The name attribute provides a unique identifier for the form, while the target attribute specifies where to display the response after form submission. Common target values include _self (same window), _blank (new window), _parent, and _top. Syntax To access form properties, use the following syntax: // Get form name document.getElementById('formId').name; // Get form target document.getElementById('formId').target; Example 1: Getting Form Name This example demonstrates how ...

Read More

How to find the accept-charset and enctype attribute of a form in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 492 Views

In HTML forms, the accept-charset and enctype attributes control character encoding and data transmission format. JavaScript provides properties to access these values programmatically. The accept-charset attribute specifies which character encodings the server accepts for form submission, while enctype defines how form data should be encoded when sent to the server. Using acceptCharset Property The acceptCharset property returns the value of the form's accept-charset attribute. Common values include "utf-8" (Unicode encoding) and "ISO-8859-1" (Latin alphabet encoding). Syntax document.getElementById('formID').acceptCharset; Example Here's how to retrieve the acceptable character set of a form: ...

Read More

Convert number to tens, hundreds, thousands and so on - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 2K+ Views

We are required to write a function that, given a number, say, 123, will output an array − [100, 20, 3] Basically, the function is expected to return an array that contains the place value of all the digits present in the number taken as an argument by the function. We can solve this problem by using a recursive approach. Example Following is the code − const num = 123; const placeValue = (num, res = [], factor = 1) => { if(num){ ...

Read More

How to display the date and time of a document when it is last modified in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 2K+ Views

In this article we are going to discuss how to display the date and time of a document when it is last modified in JavaScript. It is important to know the last updated date and time of a web document, when you read some content on the web, to know whether the web document is latest or outdated. The Document object has lastModified property which returns us the last modified date and time of a document. This is a read-only property. The value of the lastModified property is obtained by the HTTP header from the web server. ...

Read More

Checking an array for palindromes - JavaScript

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

We are required to write a JavaScript function that takes in an array of String / Number literals and returns a subarray of all the elements that were palindrome in the original array. A palindrome is a word, number, or sequence that reads the same forward and backward. For example, "dad", "racecar", and 12321 are palindromes. Problem Statement If the input array is: const arr = ['carecar', 1344, 12321, 'did', 'cannot']; Then the output should be: const output = [12321, 'did']; Approach We will create a helper function ...

Read More

What is the use of ()(parenthesis) brackets in accessing a function in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 15-Mar-2026 570 Views

The parentheses () are crucial for function invocation in JavaScript. Accessing a function without parentheses returns the function reference, while using parentheses calls the function and returns its result. Function Reference vs Function Call When you write a function name without parentheses, JavaScript treats it as a reference to the function object. With parentheses, JavaScript executes the function. Without Parentheses - Function Reference Accessing a function without parentheses returns the function definition itself, not the result: function toCelsius(f) { return (5/9) * ...

Read More

Sorting objects by numeric values - JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 523 Views

Suppose we have an object like this: const obj = { key1: 56, key2: 67, key3: 23, key4: 11, key5: 88 }; We are required to write a JavaScript function that takes in this object and returns a sorted array like this: const arr = [11, 23, 56, 67, 88]; Here, we sorted the object values and placed them in an array. Method 1: Using Object.keys() and map() This approach extracts the keys, maps them ...

Read More

How to access an object value using variable key in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 14K+ Views

In this article we are going to discuss how to access an object value using variable key in JavaScript. An object value can be accessed by a Dot Notation and a Bracket Notation. To get the object value through a variable key, the value or expression inside the bracket notation must match with the existing key name, then it returns a value. The bracket notation, unlike the dot notation can be used with variables. If we are using a variable with bracket notation, the variable must reference a string. Let's understand this concept better with the help of ...

Read More

How to set dynamic property keys to an object in JavaScript?

Lokesh Yadav
Lokesh Yadav
Updated on 15-Mar-2026 3K+ Views

Setting dynamic property keys allows you to create object properties with names that are determined at runtime. JavaScript provides three main approaches to accomplish this. Method 1: Bracket Notation The simplest way is using bracket notation to assign a value to a dynamically named property: Dynamic Property Keys - Bracket Notation Setting Dynamic Property Keys using Bracket Notation let Employee = { ...

Read More

Store count of digits in order using JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 177 Views

When working with strings containing digits, you often need to count how many times each digit appears. This is a common programming task that can be solved efficiently using JavaScript objects. Suppose we have a string with digits like this: const str = '11222233344444445666'; We need to write a JavaScript function that takes this string and returns an object representing the count of each digit in the string. For this string, the expected output should be: { "1": 2, "2": 4, "3": 3, "4": ...

Read More
Showing 3851–3860 of 6,519 articles
« Prev 1 384 385 386 387 388 652 Next »
Advertisements