- 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 9054 Articles for Front End Technology
6K+ Views
In this tutorial, we will learn how to use JavaScript to show a confirm message. We use window.confirm() method of JavaScript to show a confirm message. A confirm message is enclosed in a confirm dialog box which is a modal window. Such a window takes focus upon being created and doesn’t go out of focus until the user responds to it. Confirmation dialog box in JavaScript A confirm message is a yes/no message for the user that requires immediate attention. A confirmation dialog box usually gets triggered in response to some action requested by the user. This action can be ... Read More
1K+ Views
The onClick event is the most frequently used event type, which occurs when a user clicks the left button of the mouse. You can put your validation, warning etc., against this event type.ExampleYou can try to run the following code to call a JavaScript function from an onClick eventLive Demo Click the following button and see result
751 Views
The lifetime of a JavaScript variable begins when it is declared −var rank;A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.The completion of a function deletes the local variable.A global variable has a global scope which means it can be defined anywhere in your JavaScript code. Global variables delete when the web browser is closed. However if a new page is loaded in the same browser window, then it remains.Here’s the usage of global variables −ExampleYou can try to run the following code to learn how to ... Read More
500 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
257 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
553 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
581 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);
386 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