Found 6683 Articles for Javascript

How to test if a URL string is absolute or relative - JavaScript?

Yaswanth Varma
Updated on 18-Jan-2023 17:24:21

2K+ Views

Knowing whether or not a user has entered an absolute or relative path in your application allows you to make decisions regarding where content should be pulled from, and how certain actions should be handled. In this article, we'll go over how to use JavaScript to quickly and easily determine if a given URL string is absolute or relative. Absolute Url is a URL that includes all the data necessary for finding the resources. The protocol (HTTPS) in the site's domain at the beginning of the URL is the element that is included in the absolute URL. Following is the ... Read More

How to open link in a new window - JavaScript?

Yaswanth Varma
Updated on 18-Jan-2023 17:21:35

8K+ Views

If you have a website or web application that requires users to click on links, it can be helpful to open those links in a new window. This is especially important if the user needs to stay on your site while they view the linked content. Using JavaScript, you can easily configure all of your links so that they open in a new window when clicked. The anchor tag in HTML is used in a very simple way to open new windows and tabs. JavaScript must be used to do the same task, though. The JavaScript function window.open() is ... Read More

How to fetch character from Unicode number - JavaScript?

Yaswanth Varma
Updated on 18-Jan-2023 17:18:45

3K+ Views

In this article we are going to learn about how to fetch character from Unicode number JavaScript. Before we jump into the article let’s have a quick view on the Unicode number in JavaScript. A Unicode escape sequence in JavaScript can be used to express identifiers and string literals in Unicode. A four-digit hexadecimal value for X indicates the basic syntax, which is uXXXX. Let’s dive into the article to learn more about “How to fetch character from Unicode number JavaScript.” To retrieve character from Unicode number, use String.fromCharCode() in JavaScript String.fromCharCode() method in JavaScript The JavaScript string method charCodeAt() ... Read More

Accessing and returning nested array value - JavaScript?

Yaswanth Varma
Updated on 21-Apr-2023 16:33:16

1K+ Views

Each value in an array is referred to as an element, and each element has a certain numerical location in the array, which is referred to as its index. Nested Arrays, a feature of JavaScript, allow us to create arrays inside arrays. One or more arrays can be used as the elements of nested arrays. Although the term may be a little unclear, as we look further, it is actually rather fascinating. Accessing and returning nested array In JavaScript, a nested array is described as an Array (Outer array) inside another array (inner array). One or more inner Arrays are ... Read More

How to define custom sort function in JavaScript?

Yaswanth Varma
Updated on 18-Jan-2023 17:16:56

13K+ Views

Creating custom sort functions in JavaScript can be a great way to customize and optimize your sorting process. By defining a custom sort function, you are able to control the specific order that elements of an array will be sorted in. This article will explain how to define a custom sort function in JavaScript, provide examples of when it is useful and discuss several tips on how to make sure your sorting process is as efficient as possible. Typically, this method alters the initial array by shifting certain elements. Additionally, the sort() method converts the elements of the input ... Read More

JavaScript - Accept only numbers between 0 to 255 range?

Yaswanth Varma
Updated on 18-Jan-2023 16:04:23

487 Views

JavaScript is a popular scripting language used to create interactive websites and applications. It has many powerful features that make it easy to use and extendable. This can be useful for validating user input on forms or other data-driven tasks where you want to ensure the user enters a value within a specific range. In this article, we will discuss how to accept only numbers between 0 and 255 range using JavaScript. The range function in JavaScript returns a list of all the integers after receiving the beginning and ending indexes. The difference between the lowest and ... Read More

Convert set to object - JavaScript?

Yaswanth Varma
Updated on 18-Jan-2023 17:14:40

2K+ Views

The task we are going to perform in this article, is “Convert set to object”. Before we jump into the article, let’s have quick view on the sets and objects in JavaScript. A collection of distinctive values makes up a JavaScript Set. In a Set, a value can only appear once. Any value of any data type can be stored in a set. An object in JavaScript is a separate entity having properties and a type. Consider comparing it to a cup. A cup is an item with characteristics. A cup has a design, weight, color, material, and other ... Read More

Validate Tutorialspoint URL via JavaScript regex?

AmitDiwan
Updated on 09-Nov-2020 07:31:44

155 Views

To validate a specific URL, use regular expression.ExampleThe code is as follows −function validateSoundURL(myURL) {    var regularExpression = /^https?:\/\/(tutorialspoint\.com)\/(.*)$/;    return myURL.match(regularExpression) && myURL.match(regularExpression)[2] } console.log(validateSoundURL("https://tutorialspoint.com/index")); console.log(validateSoundURL("https://tutorialspoint.com/java"));To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo259.js.OutputThis will produce the following output on console −PS C:\Users\Amit\javascript-code> node demo259.js index java

JavaScript - Get href value

Yaswanth Varma
Updated on 21-Jun-2024 14:31:30

8K+ Views

JavaScript Get href Value is a useful tool for web developers and designers who need to quickly access the value of an HTML element's href attribute. This article will provide step-by-step instructions on how to use JavaScript to get the value of an href attribute on a webpage, as well as some tips and tricks for getting the most out of this powerful feature. The ability to quickly obtain the values from an HTML element's attributes can help make development faster and more efficient, so let's get started! The value of the href attribute in JavaScript is a URL ... Read More

Delete all text up to a character in a URL- JavaScript?

Yaswanth Varma
Updated on 18-Jan-2023 17:13:28

780 Views

This article will explain how to use the JavaScript string method 'replace()' to delete all text up to a character in a URL. We'll walk through an example of how this technique can be used for cutting off unnecessary information from a URL, and provide some helpful tips on when you might want to use this approach. A character pattern is what makes up a regular expression. The pattern is applied to text to perform "search-and-replace" operations that match patterns. A RegExp Object in JavaScript is a pattern with properties and methods. The replace() in JavaScript The replace() method ... Read More

Advertisements