- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10711 Articles for Web Development
4K+ Views
To use OR condition in JavaScript IF statement, use the || operator i.e Logical OR operator. If any of the two operands are non-zero, then the condition becomes true.Here’s how you can use the operator || in JavaScriptExampleLive Demo var a = true; var b = false; document.write("(a || b) => "); result = (a || b); document.write(result);
91 Views
The for each...in loop iterates a variable overall value of the properties of objects. Note − The “for…each..in” is now deprecated. Do not use. SyntaxHere’s the syntax −for each (variablename in object) { statement or block to execute }ExampleHere’s an example, which will not run on any of the web browsers, since “for each..in” is now deprecated − var myObj = {myProp1:30, myProp2: 40}; var sum = 0; for each (var value in myObj) { sum += value; } document.write(sum);
6K+ Views
It’s not possible to edit a JavaScript alert box title due to security issues. Still, to edit an alert box to work it all web browsers, use custom JavaScript Modal Dialogs or jQuery plugins.You can also use a custom alert box like Sweet Alert to get a custom alert box, with a title of your choice:
338 Views
To create a custom object in JavaScript, try the following codeExampleLive Demo var dept = new Object(); dept.employee = "Amit"; dept.department = "Technical"; dept.technology ="Java"; document.getElementById("test").innerHTML = dept.employee + " is working on " + dept.technology + " technology.";
200 Views
Use the super() function to call the constructor of the parent class and access functions on an object's parent class.ExampleYou can try to run the following code to implement super()Live Demo class Department { constructor() {} static msg() { return 'Hello'; } } class Employee extends Department { constructor() {} static displayMsg() { return super.msg() + ' World!'; } } document.write(Employee.displayMsg());
179 Views
for…in loopThe “for...in” loop is used to loop through an object's properties.Here’s the syntax −Syntaxfor (variablename in object) { statement or block to execute }You can try to run the following example to implement ‘for-in’ loop. It prints the web browser’s Navigator objectExampleLive Demo var aProperty; document.write("Navigator Object Properties "); for (aProperty in navigator) { document.write(aProperty); document.write(""); } document.write ("Exiting from the loop!"); for…of loopThe “for…of” loop is used to loop through iterable objects, which includes Map, Array, arguments, etc.SyntaxHere’s the syntax −for (variablename of iterable){ statement or block to execute }ExampleHere’s an example showing ... Read More
15K+ Views
The onsubmit event occurs when you try to submit a form. You can put your form validation against this event type. The following example shows how to use onsubmit. Here we are calling a validate() function before submitting a form data to the webserver. If validate() function returns true, the form will be submitted, otherwise it will not submit the data. The HTML code snippet. …
341 Views
The +function() {} notation is primarily used to force the parser to treat whatever follows the + as an expression. This is used for functions that are invoked immediately, for example,+function() { alert("Demo!"); }();However, + before a function is one of the symbol. You can add other options also like !, -, ~, also. Parentheses can also be used as shown below:(function() { alert("Demo!"); })();You can also use it like this:(function() { alert("Demo!"); }());
496 Views
When a user visits your website, they do things like click on text and images and given links, hover over things etc. These are examples of what JavaScript calls events.We can write our event handlers in JavaScript or VBScript and you can specify these event handlers as a value of event tag attribute. The HTML5 specification defines various event attributes as listed below −AttributeValueDescriptionOfflinescriptTriggers when the document goes offlineOnabortscriptTriggers on an abort eventonafterprintscriptTriggers after the document is printedonbeforeonloadscriptTriggers before the document loadsonbeforeprintscriptTriggers before the document is printedOnblurscriptTriggers when the window loses focusOncanplayscriptTriggers when media can start play but might to ... Read More