Found 2414 Articles for HTML

Match any string with p at the end of it.

Anjana
Updated on 23-Jun-2020 08:40:30

83 Views

To match any string with p at the end of it with JavaScript RegExp, use the p$ Quantifier.Example           JavaScript Regular Expression                        var myStr = "Welcome to our website! Welcome";          var reg = /me$/g;          var match = myStr.match(reg);                    document.write(match);          

How to convert Boolean to Number in JavaScript?

Shubham Vora
Updated on 08-Aug-2022 09:18:13

3K+ Views

In this tutorial, we will convert Boolean to Number in JavaScript. The Boolean is the variable's data type, which is supported by JavaScript like the other programming languages. The Boolean data type contains only two values, true and false. In some cases, programmers must convert the true or false value to the number. For example, using the strict equality operator to compare the Boolean value with the number variable. Here, using different operators, we have three methods to convert the Boolean to a number. Using the Number() Function In JavaScript, the Number() function is useful to convert any variable to ... Read More

Match any string containing a sequence of two to three p's.

Akshaya Akki
Updated on 20-Jan-2020 10:11:41

60 Views

To match any string containing a sequence of two to three p’s with JavaScript RegExp, use the p{2,3} Quantifier.Example           JavaScript Regular Expression                        var myStr = "Welcome 1, 10, 100, 1000, 1000";          var reg = /\d{2,3}/g;          var match = myStr.match(reg);                    document.write(match);          

How to add properties and methods to an object in JavaScript?

V Jyothi
Updated on 23-Jun-2020 08:32:13

177 Views

To add properties and methods to an object in JavaScript, use the prototype property.ExampleYou can try to run the following code to learn how to work with prototype −           JavaScript prototype property                function book(title, author) {             this.title = title;             this.author = author;          }                              var myBook = new book("Amit", "Java");          book.prototype.price = null;          myBook.price = 500;          document.write("Book title is : " + myBook.title + "");          document.write("Book author is : " + myBook.author + "");          document.write("Book price is : " + myBook.price + "");          

Match any string containing a sequence of N p's

Sai Nath
Updated on 23-Jun-2020 08:33:12

99 Views

To match any string containing a sequence of N p’s with JavaScript RegExp, use the p{N} Quantifier.ExampleYou can try to run the following code to match any string containing a sequence of N p’s −           JavaScript Regular Expression                        var myStr = "Welcome 1, 100, 10000, 1000";          var reg = /\d{3}/g;          var match = myStr.match(reg);                    document.write(match);          

Match any string containing zero or more p's.

Abhinaya
Updated on 23-Jun-2020 08:33:40

128 Views

To match any string containing zero or more p’s with JavaScript RegExp, use the p* Quantifier.ExampleYou can try to run the following code to match any string containing zero or more p’s. Here, p is considered as a number of occurrences −           JavaScript Regular Expression                        var myStr = "Welcome! Wweeeelcome to our website!";          var reg = /el*/g;          var match = myStr.match(reg);          document.write(match);          

Match any string containing at most one p.

Ayyan
Updated on 23-Jun-2020 08:26:03

116 Views

To match any string containing zero or one p’s with JavaScript RegExp, use the p? Quantifier.ExampleYou can try to run the following code to match any string containing zero or one p. Here p is considered a number of occurrences −           JavaScript Regular Expression                        var myStr = "Welcome 1, 100, 10000, 10000";          var reg = /10?/g;          var match = myStr.match(reg);                    document.write(match);          

How to apply a function simultaneously against two values of the array from right-to-left?

Nitya Raut
Updated on 23-Jun-2020 08:31:18

44 Views

Use the reduceRight() method in JavaScript to apply a function simultaneously against two values of the array from right-to-left as to reduce it to a single value.The following are the parameters −callback − Function to execute on each value in the array.initialValue − Object to use as the first argument to the first call of the callbackExampleYou can try to run the following code to learn how to work with reduceRight() method in JavaScript −           JavaScript Array reduceRight Method                        if (!Array.prototype.reduceRight)         ... Read More

Match any string containing one or more p's with JavaScript RegExp.

Moumita
Updated on 23-Jun-2020 08:26:48

134 Views

To match any string containing one or more p’s with JavaScript RegExp, use the p+ Quantifier.ExampleYou can try to run the following code to match any string containing one or more p’s. Here p is considered as a number of occurrences −           JavaScript Regular Expression                        var myStr = "Secure and Responsive!";          var reg = /s+/g;          var match = myStr.match(reg);                    document.write(match);          

What is the role of filter() method in JavaScript?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:21

193 Views

JavaScript array filter() method creates a new array with all elements that pass the test implemented by the provided function. The following are the parameters − callback − Function to test each element of the array. thisObject − Object to use as this when executing callback. You can try to run the following code to learn how to work with filter() method in JavaScript − Example Live Demo JavaScript Array filter Method ... Read More

Advertisements