Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Javascript Articles - Page 588 of 671
2K+ Views
This tutorial will teach us to convert a number to a Boolean in JavaScript. The variable of Boolean data type can contain only two values, true and false. When we convert the variables of any other data type to Boolean, it returns true for all non-falsy values and false for all falsy values. Let’s understand the falsy values. The JavaScript contains 6+ falsy values, and some of them are as below. Null 0 NaN False Undefined ‘ ’ From the above falsy values, we can say that for 0, we will get the false Boolean value and for ... Read More
4K+ 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
859 Views
We use the cookie property of the document object to show the name/value pairs of cookies in a document with JavaScript. The document object, part of the DOM, corresponds to the current web page that the browser has loaded. It Contains all the information about the condition of the browser as well as the web page. A server serves requests when a connection is set up and forgets everything about the user as soon as the connection is closed. This posed a nasty problem of bad user experience to the community. A cookie, resolves this problem by storing small but ... Read More
118 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);
265 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 + "");
3K+ Views
We use the window.location.hostname property of the document object to show the domain name of the server that loaded the document using JavaScript. The document object, part of the DOM, corresponds to the current web page that the browser has loaded. It Contains all the information about the condition of the browser as well as the web page. Every resource or computer that is available on the internet has an address that is either IPV4 (192.88.99.255) or IPV6 (2001:db8:3333:4444:5555:6666:7777:8888). These addresses are good for computers but not for us. domain name system is a layer of abstraction over that organization ... Read More
171 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);
195 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);
276 Views
In this tutorial, we will learn how to find the number of anchors used in an HTML document with JavaScript. Sometimes, During the development of a web page, the developer may need to add multiple links to the different buttons present on the webpage using multiple anchors for each button. In such a situation, if you want to find the number of anchor elements, you can use the anchors property. JavaScript allows us to use the anchors property to count the number of anchors ( elements) in an HTML document. Note − The document.anchors property is deprecated and no longer ... Read More
