Found 10483 Articles for Web Development

Difference between test () and exec () methods in Javascript

Abdul Rawoof
Updated on 02-Sep-2022 11:55:12

7K+ Views

The RegExp.prototype.test() and RegExp.prototype.exec() methods are the methods in JavaScript used to handle regular expressions. In addition to these two JavaScript includes a number of built-in methods for manipulating and processing text using regular expressions. What are regular expressions? Regular expressions are patterns that are used to search for character combinations in a string. Regular expressions are treated as objects in JavaScript and are denoted by either "regex" or "RegExp." The exec() method The exec() method makes a search for the specified match of the string in the given string. If the match of the string is present in the ... Read More

What is the drawback of creating true private methods in JavaScript?

Manisha Patil
Updated on 24-Aug-2022 07:09:29

406 Views

Using private methods has a simple underlying concept. In this situation, you can declare private methods or private properties, which are used to hide a class's internal functionality from those other classes, whenever you wish to keep something private, whether it be a method or a property. You can include private fields, static methods, instance methods, and getters and setters that are only accessible to you. Truly private fields and methods are delivered through private class features, with the language maintaining that privacy rather than a custom. Benefits include preventing naming conflicts between class features and the other of the ... Read More

How do you test if a value is equal to NaN in Javascript?

Lokesh Yadav
Updated on 08-Dec-2022 07:44:25

354 Views

This article discusses about how do you test if a value is equal to NaN in JavaScript. In JavaScript, NaN is a method from Number class. NaN implies Not-a-Number. It is of Boolean type. It returns true when the value is “Not-a-number”. The NaN method is used in the situations. For example, when a function tries to parse a number and it fails or when a math function fails, the method NaN is used. The syntax for isNaN() method is shown below. isNaN(); or Number.isNaN(); There is a difference between isNaN() and Number.isNaN(). If the value is currently NaN ... Read More

Which one is faster between JavaScript and an ASP script?

Lokesh Yadav
Updated on 08-Dec-2022 07:42:27

1K+ Views

In this article, we are going to discuss about the quickest language between JavaScript and ASP script. JavaScript is a light weighted and compiled language. It is a popular client-side scripting language. The content of JavaScript code is visible to the users. The extension for a JavaScript file is .js. Active Server Pages Script is popularly known as ASP script. It is a server-side scripting language to develop dynamic web pages. The extension for an ASP script file is .asp. Consider a Three-tier architecture – Presentation layer, Application layer and Data layer. JavaScript is used in the presentation layer. JavaScript ... Read More

What is JavaScript’s highest integer value that a Number can go to without losing precision?

Manisha Patil
Updated on 24-Aug-2022 10:08:44

22K+ Views

The value of the MAX SAFE INTEGER constant is 9007199254740991 (9, 007, 199, 254, 740, 991 or nine quadrillion). JavaScript only properly represents integers between -(253 - 1) and 253 - 1, which is the rationale for that number. JavaScript employs double-precision floating-point format numbers as specified in IEEE 754. Number and BigInt are the two number types available in JavaScript. Number, the most popular type of number, is a 64-bit floating point IEEE 754 number. Number.MAX SAFE INTEGER, which is the following, has the largest precise integral value of this type − 253-1, or +/- 9, 007, 199, ... Read More

Merge sort vs quick sort in Javascript

Lokesh Yadav
Updated on 09-Dec-2022 10:17:35

684 Views

In this article, we are going to discuss about the differences between merge sort and quick sort in JavaScript with appropriate examples. Merge sort and Quick sort are used to sort the elements, but the approach is different. Both Merge sort and quick sort are based on Divide and Conquer Strategy. Merge sort It is a stable sorting algorithm. In the merge sort, it follows a recursive approach that repeatedly splits the array into half until no more division is possible i.e., the array either remains empty or has a single element. Then by comparing the two small array elements ... Read More

d vs D in JavaScript?

Lokesh Yadav
Updated on 09-Dec-2022 10:16:12

3K+ Views

This article discusses about \d vs\ D in JavaScript regex. The \d and \D meta characters are used to match the characters of a given string. \d and \D are different from each other. \d (character) is equivalent to [0-9] that means it matches any single number. The characters that are not matched by the \d are matched by the \D. \D is equivalent to [^0-9] that means it matches any character other than number. Both \d and \D are completely inverse to each other. To match a string with a pattern, the possible methods are: string.match(pattern), string.search(pattern), pattern.exec(string), pattern.test(text). ... Read More

w vs W in JavaScript regex?

Lokesh Yadav
Updated on 09-Dec-2022 10:13:21

4K+ Views

This article discusses about the \w vs \W in JavaScript regex. The \w and \W meta characters are used to match the characters of a given string. \w and \W are different from each other. \w (character) is equivalent to [a-zA-Z0-9_] that means it matches any single letter, number, or underscore. The characters that are not matched by the \w are matched by the \W. \W is equivalent to [^a-zA-Z0-9_] that means it matches any character other than letter, number and underscore. To match a string with a pattern, the possible methods are: string.match(pattern), string.search(pattern), pattern.exec(string), pattern.test(text). We use match ... Read More

Why is using “for…in” loop in JavaScript array iteration a bad idea?

Manisha Patil
Updated on 24-Aug-2022 12:51:25

247 Views

The ability to execute a collection of instructions or functions repeatedly while a certain condition holds true is known as looping in programming languages. The for-in statement is used to iterate through the properties of an object. This sentence will move up the prototype chain and display all inherited properties, which is usually undesirable. When it comes to iterating through array elements, there are few reasons why you shouldn't use for..in: For example, if someone changes Array.prototype, which is absolutely bad practise in code that is meant to operate well with the other scripts, for..in will cycle over all ... Read More

How to convert a string into integer in JavaScript?

Lokesh Yadav
Updated on 20-Sep-2024 13:21:50

212K+ Views

To convert a string into integer in JavaScript, is a simple task and can be converted using various approaches. Converting string to integer is useful for performing accurate mathematical operations, comparisons and validating user input. We will be discussing various approaches in this article to convert a string into integer in JavaScript In this article, we are having a string value, our task is to convert string to integer in JavaScript. Approaches to Convert String to Integer in JavaScript Here is a list of approaches to convert string to integer in JavaScript which we will be discussing in this ... Read More

Advertisements