JavaScript RegEx test() method

The JavaScript RegExp test() method is used to search for a match between a regular expression and a specified string. Syntax: RegExpObject.test(string); Parameters: string: It represents the string to be searched. Return: It returns true if the match between a regular expression and a specified string is found otherwise returns false. Example: <!DOCTYPE html> <html> … Read more

JavaScript RegEx exec()

The JavaScript RegExp exec() method is used to get an array containing all the matched groups for a specified string. Syntax: RegExpObject.exec(string) Parameters: string: It represents the string to be searched. Return: An array containing all the matched groups for a given string. Example: <!DOCTYPE html> <html> <body> <script> var string = “HELLO WORLD”; var … Read more

JavaScript RegExp tutorial

A regular expression refers to the object which represents the pattern of characters. JavaScript provides the RegEx class which provides theĀ pattern-matching and search-and-replace functionality on text. Syntax: /pattern/modifiers Modifiers Modifiers are used to perform case-insensitive and global searches. Modifier Description g It is used to find all matches. i It is used to perform case-insensitive … Read more

JavaScript Number isSafeInteger() method

All integers which can be represented as an IEEE-754 double-precision number are considered safe integers. JavaScript Number.isSafeInteger() is used to check whether the given number is a safe integer or not. Syntax: Number.isSafeInteger(number) Parameters number: It represents the number on which safe integer checks have to be informed. Returns It returns true if the specified … Read more

toString Number JavaScript JS

The JavaScript number toString() method is used to get a number in the form of a string. Syntax: Number.toString(radix) Parameters radix: It represents the number format. Its value can be between 2 to 36. e.g. If the value is 2 then the number format will be binary. Returns String representation of the specified number. Example: … Read more

JavaScript Number toPrecision() method

The JavaScript number toPrecision() method is used to get the string representing a number of specified precision or length. Syntax: Number.toPrecision(n) Parameters n: It represents the total number of digits. Returns String representation of a number of specified precision. Example: <!DOCTYPE html> <html> <body> <script> var n= 12.334; document.writeln(n.toPrecision(4)); </script> </body> </html>

toFixed Number JavaScript JS

The JavaScript number toFixed() method is used to get the string that represents a number with exact digits after a decimal point. Syntax: Number.toFixed(n) Parameters n: It represents the number of digits after the decimal point. Returns String representation of the specified number with exact digits after a decimal point. Example: <!DOCTYPE html> <html> <body> … Read more

JavaScript Number toExponential() method

The JavaScript number toExponential() method is used to get the string that represents the exponential notation of a number. Syntax: Number.toExponential(n) Parameters n: It represents the number of digits after the decimal point. It is an optional parameter. Returns Exponential notation of a number as string. Example: <!DOCTYPE html> <html> <body> <script> var n= 12.334; … Read more

parseInt Number JavaScript JS

The JavaScript number parseInt() method is used to convert a string into an Integer number. Syntax: Number.parseInt(string, radix) Parameters string: It represents the string that has to be converted into an integer number. It is a required parameter. radix: It represents the number format. It is an optional parameter. Returns Integer number. Example: <!DOCTYPE html> … Read more