Different Ways of Defining Functions in JavaScript

Shubham Vora
Updated on 15-Nov-2022 09:27:24

908 Views

In this tutorial, we will learn the different ways of defining functions in JavaScript. In programming, writing the same code again and again is not a great idea. It will increase the length and decrease the readability with more effort required for the program. The functions are there in the programming languages to make it easier for programmers. The function is like a container containing certain lines of programs inside. The function does not execute by only defining it. We have to call it somewhere in the program by which it can run the code it consists of. We can ... Read More

Regular Expression to Match Numbers Only in JavaScript

Shubham Vora
Updated on 15-Nov-2022 09:22:47

5K+ Views

In this tutorial, we will learn regular expressions to match numbers only in JavaScript. Data is a core element in every webpage. We have to validate it as per the requirements. We often deal with the data and require correct input from the user. For example, the user can not put the letters inside the field to accept the phone number, or the input length should be ten numbers. To validate the data in JavaScript, regular expression is used. We often need to filter the necessary data and extract the matched data. Here, we are going to match all the ... Read More

Boolean Typed Array in JavaScript

Shubham Vora
Updated on 15-Nov-2022 09:19:41

397 Views

In this tutorial, we will learn if there is a Boolean Typed Array in JavaScript. Typed Arrays are the objects same as arrays by using we can read or write raw binary data. It is useful to carry advanced information that contains lots of data like audio or videos fast and without distortion compared to our traditional way. The machine can only understand 0s and 1s. The typed arrays saved the information in an array of binary data. So, it becomes easier to transport the data from one end to another. Now come to the question- Is there a Boolean ... Read More

Work with Document Head in JavaScript

Shubham Vora
Updated on 15-Nov-2022 09:14:52

2K+ Views

In this tutorial, let us discuss how to work with the document's head in JavaScript. The document head property is a dom level 3 read-only feature. The document's head property returns all the head tags in the document. HTML adds an empty head tag in case it is not present. The property returns the first head element in case there are many. The head tag contains the document header information like title, keywords, description, and style sheet. Every document needs a head tag. But start and end tags are optional. The first body tag or the first frameset tag becomes ... Read More

Work with Document Anchors in JavaScript

Shubham Vora
Updated on 15-Nov-2022 09:12:14

852 Views

In this tutorial, let us discuss how to work with the document's anchor in JavaScript. Relevant web technologies no longer recommend this property. Some browsers still recommend it for compatibility reasons. The document anchor property is a read-only feature that returns all the anchor tags. The anchor tag represents the start and end of a hyperlink. The anchor tag attributes are name, href, rel, rev, title, urn, and method. All attributes are optional. But a name attribute is mandatory for document anchors to work. Working with anchor’s properties Let us learn to work with an anchor's properties. Users can follow ... Read More

Work with Structs in JavaScript

Shubham Vora
Updated on 15-Nov-2022 09:06:39

8K+ Views

In this tutorial, let us discuss how to work with structs in JavaScript. What is a struct? A struct is the short name of the data structure. The structure creates multiple values of different types in a single variable. We can use a struct to generate records. A struct in JavaScript is the object creation. Other than that, JavaScript does not have a struct feature. Let us see the methods to create a structure. Using the String split() Method Let us learn to create a struct using string split. Separate a string with a comma and whitespace and give it ... Read More

Validate a Given Number in JavaScript

Shubham Vora
Updated on 15-Nov-2022 09:02:03

4K+ Views

In this tutorial, let us discuss how to validate a given number in JavaScript. Users can follow the syntax below each method to use it. Using regular expression The method tests or matches the regular expression with the input. Syntax /\D/.test(input); input.match(/^[0-9]*$/); If the input is a number, the test returns true. Example The program succeeds in all cases except for "30", [], and "". Number validation using regular expression Validate ... Read More

Set Width of Top Border with JavaScript

Shubham Vora
Updated on 15-Nov-2022 08:16:51

279 Views

In this tutorial, we will learn how to set the width of the top border with JavaScript. The border of an element is the outer part of the element. The border width for each side can be set with different JavaScript properties. For example, to set the width of the top border in JavaScript, use the borderTopWidth property. There are two approaches to specifying the width of the top border − Using the setProperty method Using the borderTopWidth property Using the setProperty method to set the width of the top border In JavaScript, any property of an element, ... Read More

Set Type of Quotation Marks for Embedded Quotations in JavaScript

Shubham Vora
Updated on 15-Nov-2022 08:14:18

526 Views

In this tutorial, we will learn how to set the type of quotation marks for embedded quotations with JavaScript. The types of quotation marks can be changed using JavaScript. For example, if a sentence is in double quotes(“”), it can be modified to single quotes(‘’). To set the quotation, use the element. With that, add the type of quotation marks with the quotes property. Using the quotes property to set the type of quotation marks In JavaScript, the quotes property is used to set the type of quotation marks for embedded quotations. The quotation marks can be set using ... Read More

Convert String to Uppercase Letters in JavaScript

Shubham Vora
Updated on 15-Nov-2022 08:08:31

302 Views

In this tutorial, we will learn how to convert a string to uppercase letters for the host's locale in JavaScript. While using a locale language to write for a website, we might have to convert the sentence from lowercase to uppercase without changing the structure of the string. Using the toLocaleUpperCase() Method In JavaScript, we use the toUpperCase() Method as well as the toLocaleUpperCase() to change the letters of a string to uppercase. Although both methods give similar output the toLocaleUpperCase() is used primarily for local languages. Syntax We will use the following syntax to convert the letters of the ... Read More

Advertisements