Found 8894 Articles for Front End Technology

How to get the length of a string in bytes in JavaScript?

Naveen Singh
Updated on 18-Oct-2022 12:35:40

3K+ Views

In this tutorial, we are going to learn how can we get the length of a string in bytes in JavaScript. Before going into this we should what a byte is. A byte is a unit of data that is 8 binary bits long i.e., 1 byte can hold up to 8 bits of binary data. A byte is a unit most computers use to represent a character such as a letter, number, or typographic symbol. Some examples of strings and their length in bytes are given − Input "Tutorials Point" Output 15 bytes Input 20€ Output 5 bytes Input ... Read More

How to find all elements in a given array except for the first one using JavaScript?

Naveen Singh
Updated on 18-Oct-2022 12:29:34

1K+ Views

In this tutorial, we are going to find all the elements present in the given array except the first element using JavaScript. Here we will create one array and using JavaScript will print all the elements on the HTML page leaving the first element. There are mainly two approaches we can use to do the above task. Both the methods are given as − Approach 1: By using the slice() Method The slice() method is a JavaScript method that is used to slice out the required amount of elements from the array. Syntax The following syntax can be used with ... Read More

How to find every element that exists in any of two given arrays once using JavaScript?

Naveen Singh
Updated on 18-Oct-2022 12:25:46

175 Views

In this tutorial, we are going to learn how can we find every element that exists in any of the two given arrays once means we need to take two arrays filled with some elements and then from those two arrays create a new array which contains all the elements present in both the array once i.e., no element should be repeated in the new array created. For example, we take two arrays and find every element that exists in any of the two arrays once Input const arr1 = [1, 2, 3, 4, 5] const arr2 = [1, 4, ... Read More

How to find the binomial coefficient of two integers using JavaScript?

Naveen Singh
Updated on 18-Oct-2022 12:22:21

325 Views

In this tutorial, we are going to learn how to find the binomial coefficient of two integers using JavaScript. Before learning it we should know what binomial coefficient is and what it refers to. What are Binomial Coefficients? Binomial coefficients refer to the positive integers that occur as coefficients in the binomial theorem. A binomial coefficient C(n, k) can be defined as the coefficient of x^k in the expansion of (1 + x)^n. A binomial coefficient of two numbers n and k signifies the number of combinations of r items that can be selected from a set of n items. ... Read More

What is Unary Plus Operator in JavaScript?

Naveen Singh
Updated on 18-Oct-2022 12:16:07

243 Views

Unary operators are the simplest operators in JavaScript which works on one value, or we can say on one operand. There are mainly six kinds of unary operators in JavaScript which are given as − Unary Plus Unary Minus Increment operator (Prefix) Increment operator (Postfix) Decrement operator (Prefix) Decrement operator (Postfix) In this tutorial, we are going to learn about the unary plus (+) operator. To use the unary plus operator we just need to put a plus sign in front of the operand. This operator is basically used to convert a non-numeric value to a numeric value, ... Read More

How to design hit the mouse game using HTML, CSS and JavaScript?

Naveen Singh
Updated on 18-Oct-2022 12:03:55

458 Views

In this tutorial, we are going to build the famous hit the mouse game using HTML, CSS, and vanilla JavaScript. Many of you wondering what is Vanilla JavaScript, it is nothing just plain JavaScript written without the use of any libraries. In the hit the mouse game, the player needs to hit the mouse with the hammer in order to earn points and win the game. Approach To design the mouse game, we need to write the code IN HTML, CSS, and JavaScript. Step 1 − Firstly, let us look into the HTML part of the code; in this part, ... Read More

How to Create Pong Game in JavaScript?

Naveen Singh
Updated on 18-Oct-2022 11:44:19

2K+ Views

A Pong game is a two-player paddle game where each player’s task is to save the ball from hitting the wall. Whenever player 1 hits the ball at the opponent’s wall then player one will receive a point, and similarly, player 2 will get a point if he/she hits the ball at the opponent’s wall. In this tutorial, we will create a Pong Game in JavaScript. Approach To make the pong game using JavaScript we need to write code in HTML, CSS, and JavaScript. We have written certain functions in JavaScript to build the Pong game which is defined below ... Read More

How to apply CSS to iframe?

AmitDiwan
Updated on 18-Oct-2022 08:22:01

7K+ Views

Define an inline frame with HTML tag . The tag is not somehow related to tag, instead, it can appear anywhere in your document. The tag defines a rectangular region within the document in which the browser can display a separate document, including scrollbars and borders. The src attribute is used to specify the URL of the document that occupies the inline frame. We can easily apply CSS to an iframe, but let us first look at the attributes of the − src − This attribute is used to give the file name that should ... Read More

How to use tables to structurize forms in HTML?

AmitDiwan
Updated on 18-Oct-2022 08:12:52

277 Views

The tables can be used to create and structurize forms in HTML. But, before that let us see how to create a form in HTML. Create a Form in HTML Example Let us see how to create a form using the tags. We have set three input type radio with individual labels − DOCTYPE html> HTML Form Details Select the subject you want to choose: ... Read More

How wide is the default margin?

AmitDiwan
Updated on 18-Oct-2022 08:05:28

2K+ Views

The default margin is 8px in HTML. It is defined in pixels by the user-agent-stylesheet your browser provides. Some browsers allow you to create and use your own user-agent-stylesheet, but if you are developing a website, keep it the same. Default Margin in HTML Example Let us see a simple example. Here, since the default margin is 8px, we won’t try to change it − DOCTYPE html> Example body { background: orange; ... Read More

Advertisements