Found 2202 Articles for HTML

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

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

107 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

256 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

164 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

186 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

173 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

91 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

199 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

269 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

How to represent the source code of an object with JavaScript Arrays?

Govinda Sai
Updated on 23-Jun-2020 08:28:59

265 Views

JavaScript array toSource() method returns a string representing the source code of the array. This method is supported by Mozilla.ExampleYou can try to run the following code to learn how to represent the source code of an object with JavaScript Arrays −           JavaScript Array toSource Method                        var arr = new Array("football", "baseball", "volleyball", "cricket");                  var str = arr.toSource();          document.write("Returned string is : " + str );          

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

Manikanth Mani
Updated on 23-Jun-2020 08:28:25

187 Views

Use the reduce() method in JavaScript to apply a function simultaneously against two values of the array from left-to-right 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 callback.ExampleYou can try to run the following code to learn how to work with reduce() method in JavaScript −           JavaScript Array reduce Method                        if (!Array.prototype.reduce) {     ... Read More

Advertisements