
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
Found 6710 Articles for Javascript

662 Views
JavaScript's interaction with HTML is handled through events that occur when the user or the browser manipulates a page.When the page loads, it is called an event. When the user clicks a button, that click to is an event. Other examples include events like pressing any key, closing a window, resizing a window, etc.Here are some examples:onclick Event TypeThis is the most frequently used event type, which occurs when a user clicks the left button of his mouse. You can put your validation, warning etc., against this event type.Try the following example.Live Demo ... Read More

494 Views
A block statement groups zero or more statements. In languages other than JavaScript, it is known as a compound statement.SyntaxHere’s the syntax −{ //List of statements }To add a label to a block, use the following −Identifier_for_label: { StatementList }Let’s use it for break statement. You can try to run the following code to use labels to control the flow, with break statementExampleLive Demo document.write("Entering the loop! "); outerloop: // This is the label name for (var i = ... Read More

733 Views
The usage of “continue” statement makes the code difficult to understand. In most cases, the usage of continue would mean you have an insufficient condition in your loop. To avoid this, you can add it to the condition itself or use if in a loop.But, “continue” is bad if it is used inconsistently or improperly, else it is a useful statement and saves a lot of memory and lines of code.ExampleLet’s see an example of continue statementLive Demo var x = 1; document.write("Entering the loop "); ... Read More

917 Views
A block statement groups zero or more statements. In languages other than JavaScript, it is known as a compound statement.SyntaxHere’s the syntax −{ //List of statements }Variables with a block get scoped to the containing function. Block statement never introduce scope and using var to declare variables don’t have block scope.var a = 20; { var b = 40; }Now, when you will print the value of a, it will print 40, not 20. This is because variable declared with a var within the block has the same scope like var before the block.var a = 20; { var a = 40; } // this prints 40 document.write(a);

561 Views
Break without labelThe break statement is used to exit a loop early, breaking out of the enclosing curly braces. The break statement exits out of a loop. ExampleLet’s see an example of break statement in JavaScript without using label −Live Demo var x = 1; document.write("Entering the loop "); while (x < 20) { if (x == 5){ break; // breaks out ... Read More

200 Views
The most common way to define a function in JavaScript is by using the “function” keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces.SyntaxHere’s the syntax − Try the following example. It defines a function called sayHello that takes no parameters,