Found 9053 Articles for Front End Technology

Understanding function scope and context in JavaScript?

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

164 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

144 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

67 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 set background color in HTML?

Lokesh Badavath
Updated on 29-Aug-2023 07:08:04

229K+ Views

Setting the background color of a web page or an element on the web page, enable us to create unique layouts for the web page. To set the background color in HTML, use the style attribute, with the CSS property background-color inside the body tag of the HTML document. HTML5 do not support the tag bgcolor attribute, so the CSS style is used to add background color. The bgcolor attribute deprecated in HTML5. We can change the background color by overriding the property with the other property. Syntax Example Following is the example program to set background ... Read More

How to concatenate multiple string variables in JavaScript?

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

17K+ 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 link to send email in HTML?

Lokesh Badavath
Updated on 18-Nov-2022 09:53:52

2K+ Views

We use HTML tag defines a hyperlink used to link web pages. The href attribute of the tag, which indicates the link's destination. Which provides us option to specify an email address. To create a link to send mail we use mailto:to specify email address inside href attribute in HTML. Syntax Following is the syntax to link a mail address to the web page. xx@gmail.com Same as the way we link a mobile number. We use mailto instead of tel inside a href attribute. Example Following is the example program to link a mail address to the ... Read More

Why do we use head tag in HTML Page?

Lokesh Badavath
Updated on 11-Nov-2022 08:15:36

2K+ Views

The tag is a container for all the head elements in an HTML page. We use … tag to add it to HTML page. head tag contains the title of the document, styles, scripts, and other HTML elements. The element is a container for metadata-data about data and is placed between the … tag. The following elements can go inside the element − − Use in every HTML page defines the title of the content. − Used to apply a simple style to HTML document − Specify a default URL and a default ... Read More

How to Insert Hyperlink in HTML Page?

Bhanu Priya
Updated on 05-Oct-2023 12:18:46

157K+ Views

To insert a hyperlink in a HTML page, we have to utilize the anchor tags and labels, which are used to characterize the connections. The tag demonstrates where the hyperlink begins and the < / a> tag shows where it closes. Whatever text gets added inside these labels, will function as a hyperlink. Add the URL for the connection in the Following is the usage of hyperlinks − < html> ... -- text < / a> In the HTML, ... Read More

How to use image height and width attribute in HTML Page?

Lokesh Badavath
Updated on 11-Nov-2022 08:13:37

1K+ Views

Images make content more interesting by helping readers to understand the content better on the web page. We can insert images into the HTML page. To insert image in an HTML page, use the tags. It is an empty tag, containing only attributes since the closing tag is not required. The src attribute is used to add the image source which is the URL of the image(location of the file). The alt attribute is for adding alternate text, width is for adding width, and height is for adding the height of the image. We use style attribute to ... Read More

How to use href attribute in HTML Page?

Lokesh Badavath
Updated on 11-Nov-2022 08:11:28

2K+ Views

The href attribute specifies the URL of the page the link goes to (href attribute specifies the link's destination). We should use href attribute with tag so it will be a hyperlink. This tag should be used inside the … tags. Syntax Following is the syntax for the tag, which uses href attribute to specify the link address. link text Example Following is the example program to use href attribute in an HTML page. DOCTYPE html> Click this to navigate to the Brave home page How ... Read More

Advertisements