Javascript Articles

Page 11 of 534

What are label statements in JavaScript?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 4K+ Views

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 More

What is onclick event in JavaScript?

vanithasree
vanithasree
Updated on 11-Mar-2026 683 Views

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 More

What is the difference between break with a label and without a label in JavaScript?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 621 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 −                            var x = 1;          document.write("Entering the loop ");                  while (x < 20) {             if (x == 5){                break; // breaks out of ...

Read More

What is the lifetime of JavaScript variables?

Govinda Sai
Govinda Sai
Updated on 11-Mar-2026 1K+ 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

How to call a JavaScript function from an onClick event?

varun
varun
Updated on 11-Mar-2026 2K+ 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 event                                         Click the following button and see result                          

Read More

How to call a JavaScript function from an onmouseover event?

varma
varma
Updated on 11-Mar-2026 2K+ Views

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 More

How to create a dialog with &ldquo;yes&rdquo; and &ldquo;no&rdquo; options in JavaScript?

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 3K+ Views

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 More

What is the difference between closure and nested functions in JavaScript?

mkotla
mkotla
Updated on 11-Mar-2026 1K+ Views

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 More

How to turn a String into a JavaScript function call?

Smita Kapse
Smita Kapse
Updated on 11-Mar-2026 569 Views

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 More

How can I pop-up a print dialog box using JavaScript?

Amit Sharma
Amit Sharma
Updated on 11-Mar-2026 4K+ Views

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
Showing 101–110 of 5,339 articles
« Prev 1 9 10 11 12 13 534 Next »
Advertisements