Found 6710 Articles for Javascript

How to create a link to send email with a subject in HTML?

Ayyan
Updated on 09-Jan-2020 06:49:01

21K+ Views

To create a link to send email, use tag, with href attribute. The mail to link is added inside the tag. To add a subject, you need to add ? and then include the subject. All this comes inside the tag.Just keep in mind to add the email address where you want to receive the email in the mail to link. Also, the spaces between words for the subject shouldn’t be space, instead include %20. This is to ensure the browser displays the text properly.ExampleYou can try to run the following code to create a link to ... Read More

Understanding function scope and context in JavaScript?

Shubham Vora
Updated on 15-Nov-2022 10:41:11

322 Views

In this tutorial, let us discuss the function scope and context in JavaScript. Functions are the building blocks of Javascript. Therefore, JavaScript is a functional programming language. Scope The 'scope' is the code space where we can define and use a variable in a function. Scopes are of four types. Global scope Global 'scope' is the default scope. A variable with global 'scope' is accessible throughout the program. Browser closing removes a global variable. Window objects can access var variables wherein they can't access the let variables. Functional or local 'scope' A function variable is accessible only with the function. ... Read More

How to call functions in JavaScript?

Ankitha Reddy
Updated on 09-Jan-2020 06:48:02

236 Views

A function is a group of reusable code which can be called anywhere in your program. This eliminates the need of writing the same code repeatedly. It helps programmers in writing modular codes.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.Here’s an example −     To call a function somewhere later in the script, you would simply need to write the name of that function as shown in the following ... Read More

How to arguments object with Rest, default, and destructured parameters in JavaScript?

Abhinaya
Updated on 15-Jun-2020 13:19:37

169 Views

defaultThis came to handle function parameters with ease. Easily set Default parameters to allow initializing formal parameters with default values. This is possible only if no value or undefined is passed. Let’s see an exampleExampleLive Demo                    // default is set to 1          function inc(val1, inc = 1) {             return val1 + inc;          }          document.write(inc(10, 10));          document.write("");          document.write(inc(10));           restES6 ... Read More

How to concatenate multiple string variables in JavaScript?

Shubham Vora
Updated on 08-Aug-2022 11:38:55

18K+ Views

In this tutorial, we will learn to concatenate the multiple string variables in JavaScript. It’s many times needed that we need to concatenate two strings in a single variable and use it. The simple meaning of concatenation is to merge two or multiple strings. Also, string concatenation is useful to insert some substring in the parent string. For example, while developing the application, as a programmer, you need to update the string by adding some other extra string to it. Users can split the string first and insert the substring using the concatenation operation. There are various methods to merge ... Read More

How to create a dialog with “yes” and “no” options in JavaScript?

Anvi Jain
Updated on 30-Jul-2019 22:30:21

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.ExampleLive Demo                          function functionConfirm(msg, myYes, myNo) {             var confirmBox = $("#confirm");             confirmBox.find(".message").text(msg);             confirmBox.find(".yes, .no").unbind().click(function() {                confirmBox.hide();             });         ... Read More

How to change button label in alert box using JavaScript?

Shubham Vora
Updated on 02-Aug-2022 13:46:21

4K+ Views

In this tutorial, we will learn to change the button label in the alert box using JavaScript. The alert box is one kind of popup box that is useful to show some important information to the user. We can pop up the alert box using JavaScript's alert() method. The default alert box contains the simple message and ok button, which pops out at the top center of the browser's screen. The default alert box with only messages and without any style looks weird. So, we need to make it stylish and change the style of the button and the label ... Read More

How to call a JavaScript function from C++?

Akansha Kumari
Updated on 29-May-2025 19:05:56

1K+ Views

Calling a JavaScript function directly from C++ depends on the environment and the system; for this, make sure you have embedded a JavaScript engine or integrated C++ with JavaScript. In this article, we will be using Emscripten (C++ to JavaScript in WebAssembly) to call a JavaScript function from C++. For this, you have to compile the C++ program to WebAssembly using Emscripten and then call JavaScript functions from C++. So, first, create the C++ file with the header . C++ File Let's consider that this file name is saved as main.cpp. #include // here declared an external JS ... Read More

Why should we use a semicolon after every function in JavaScript?

radhakrishna
Updated on 16-Jun-2020 11:41:07

815 Views

Adding semicolons after every function is optional. To avoid undesirable results, while using functions expressions, use a semicolon.Using semicolonvar display = function () {   alert(“Hello World”); }; (function () {   // code })();Without using semicolonvar display = function () {   alert(“Hello World”); } (function () {   // code })();The first function executes immediately since we have used the semicolon.

How to trigger event in JavaScript?

Vikal Singh
Updated on 03-Oct-2019 06:38:20

844 Views

The trigger() method triggers the specified event and the default behaviour of an event (like form submission) for the selected elements.For example: $( "#foo" ).on( "click", function() {   alert( $( this ).text() ); }); $( "#foo" ).trigger( "click" );

Advertisements