Lokesh Yadav

Lokesh Yadav

38 Articles Published

Articles by Lokesh Yadav

Page 4 of 4

Merge sort vs quick sort in Javascript

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

Merge Sort and Quick Sort are two popular divide-and-conquer sorting algorithms in JavaScript. While both are efficient, they differ in their approach, stability, and performance characteristics. Merge Sort Overview Merge Sort is a stable sorting algorithm that recursively divides the array into halves until each sub-array contains a single element, then merges them back in sorted order. It guarantees O(n log n) time complexity in all cases but requires additional space for merging. Quick Sort Overview Quick Sort selects a pivot element and partitions the array around it, placing smaller elements to the left and larger ...

Read More

Which one is faster between JavaScript and an ASP script?

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

In this article, we are going to discuss the performance differences between JavaScript and ASP script in web development contexts. JavaScript is a lightweight, interpreted language primarily used for client-side scripting. It executes directly in the browser, making the code visible to users. JavaScript files use the .js extension. Active Server Pages Script (ASP) is a server-side scripting technology used to create dynamic web pages. ASP files have the .asp extension and execute on the web server before sending results to the client. Architecture and Execution Context In a three-tier architecture (Presentation, Application, and Data layers), ...

Read More

How to encode a string in JavaScript?

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

In JavaScript, string encoding converts text into different formats for various purposes like URL handling, Base64 encoding, or data transmission. JavaScript provides several built-in methods for encoding strings depending on your specific needs. Encoding is the process of converting data from one format to another. Unlike encryption, encoding doesn't require keys and is primarily used to ensure data remains usable across different systems and protocols. Using btoa() Method The btoa() method encodes a string into Base64 format, which is commonly used for data transmission and storage. Syntax btoa(string) Where string is the text ...

Read More

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

Insert a specified HTML text into a specified position in the JavaScript document?

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

The insertAdjacentHTML() method allows you to insert HTML content at specific positions relative to an existing element in the DOM. This method provides four position options and is more efficient than using innerHTML for adding content. Syntax element.insertAdjacentHTML(position, text); Parameters element − The target HTML element where content will be inserted position − One of four values: "beforebegin", "afterbegin", "beforeend", "afterend" text − The HTML string to insert Position Options Explained Target Element ...

Read More

Insert a specified element in a specified position in JavaScript?

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

In JavaScript, the insertAdjacentElement() method allows you to insert an existing DOM element at a specific position relative to another element. This method is useful for dynamically rearranging elements without removing them from the DOM first. Syntax element.insertAdjacentElement(position, elementToInsert); Parameters element - The target element where the new element will be positioned relative to position - A string specifying where to insert the element. Four possible values: 'beforebegin' - Before the target element 'afterbegin' - Inside the target element, as the first child 'beforeend' - Inside the target element, as the last ...

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 478 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

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
Showing 31–38 of 38 articles
« Prev 1 2 3 4 Next »
Advertisements