Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Javascript Articles
Page 11 of 534
What are label statements in JavaScript?
JavaScript label statements are used to prefix a label to an identifier. A label can be used with break and continue statement to control the flow more precisely. A label is simply an identifier followed by a colon (:) that is applied to a statement or a block of code. We will see two different examples to understand how to use labels with break and continue.ExampleYou can try to run the following code to use labels to control the flow, with break statement document.write("Entering the loop! "); ...
Read MoreWhat is onclick event in JavaScript?
The onClick event is the most frequently used event type, which occurs when a user clicks the left button of the mouse.ExampleYou can put your validation, warning etc., against this event type. Click the following button and see result
Read MoreWhat is the difference between break with a label and without a label in JavaScript?
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 − var x = 1; document.write("Entering the loop "); while (x < 20) { if (x == 5){ break; // breaks out of ...
Read MoreWhat is the lifetime of JavaScript variables?
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 MoreHow to call a JavaScript function from an onClick event?
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 event Click the following button and see result
Read MoreHow to call a JavaScript function from an onmouseover event?
The onmouseover event triggers when you bring your mouse over any element.ExampleYou can try to run the following example to learn how to call a JavaScript function from onmouseover event Bring your mouse inside the division to see the result: This is inside the division
Read MoreHow to create a dialog with “yes” and “no” options in JavaScript?
No, you cannot create a dialog box with “yes” or “no”. A confirmation dialog box in JavaScript has “Ok” and “Cancel” button.To create a dialog with “yes” or “nor”, use a custom dialog box.Example function functionConfirm(msg, myYes, myNo) { var confirmBox = $("#confirm"); confirmBox.find(".message").text(msg); confirmBox.find(".yes, .no").unbind().click(function() { confirmBox.hide(); }); ...
Read MoreWhat is the difference between closure and nested functions in JavaScript?
JavaScript ClosuresIn JavaScript, all functions work like closures. A closure is a function, which uses the scope in which it was declared when invoked. It is not the scope in which it was invoked.Here’s an example JavaScriptClosures varp = 20; functiona(){ var p = 40; b(function(){ alert(p); }); ...
Read MoreHow to turn a String into a JavaScript function call?
To turn a string into a JavaScript function call, try to run the following codeExample function myFunction(argument) { alert('My function ' + argument); } functionName = 'myFunction'; window[functionName]('is working.');
Read MoreHow can I pop-up a print dialog box using JavaScript?
To pop-up a print dialog box using JavaScript, use the print() method. With the dialog box, you can easily set the printing options like which printer to select for printing.This is the dialog box −ExampleYou can try to run the following code to learn how to print a page − Click to Print function display() { window.print(); }
Read More