Found 8894 Articles for Front End Technology

How to check the type of a variable or object in JavaScript?

Rushi Javiya
Updated on 08-Feb-2023 20:34:54

11K+ Views

JavaScript is a loosely typed programming language, meaning there is no such rule to declare the variable type. A variable can store multiple data types in a program, so it is essential to understand the variable type before using it. In JavaScript, we can use the typeof operator to check the type of a variable or object. The typeof operator takes a variable and returns its type in a string format. In addition, to the typeof operator, JavaScript also provides the instanceof operator to check the type of a variable or object. The instanceof operator accepts two arguments: the ... Read More

How to Check Mentioned File Exists or not using JavaScript/jQuery?

Rushi Javiya
Updated on 08-Feb-2023 20:37:26

6K+ Views

Using JavaScript or jQuery, we can check whether a file exists and retrieve metadata about the file, such as its size, content type, last modified date, etc., without retrieving the actual file. The HTTP HEAD request is used in this case. An HTTP HEAD request is a type of HTTP request that asks the server to return the HTTP headers for a specified resource without the actual resource itself. Several methods can be used to send an HTTP HEAD request, but the most popular way is to use the $.ajax() method and XMLHttpRequest object. Users can define the request ... Read More

How to use template string literal in ECMAScript 6?

Rushi Javiya
Updated on 08-Feb-2023 21:17:14

182 Views

In the ES6 version of JavaScript, literals are introduced. JavaScript contains object literals, array literals, Numeric literals, RegExp literals, etc. Also, it contains the string literals. The string literal allows us to create multiline strings without any backslash characters, add any word or sentence to the quote, and add variables and mathematical expressions in between the strings. Syntax Users can follow the syntax below to use the template string literal in ECMAScript 6. let string = `This is template literal string!`; In the above syntax, we have used the backticks (` `) to create a template literal string. ... Read More

How to add fade-out effect using pure JavaScript?

AmitDiwan
Updated on 06-Feb-2023 12:38:59

7K+ Views

We can add a fade-out effect using pure JavaScript by manipulating the element's style property. We can start by setting the element's opacity to 1 and then gradually decreasing it over time using the setInterval or setTimeout function. Finally, we can remove the element from the DOM once the opacity reaches 0. Fade-out Effect A fade-out effect is a visual transition where an element gradually becomes less visible over a period of time. This effect is commonly used in web design and animation to create a smooth transition between elements on a page or to hide an element from view. ... Read More

How to add default vertical scaling to a text canvas using Fabric.js?

AmitDiwan
Updated on 06-Feb-2023 12:34:19

227 Views

We can add default vertical scaling to a text canvas using Fabric.js by first creating a text object and then setting the "scaleY" property to the desired scaling value. Additionally, we can use the "setCoords()" method to update the object's coordinates to reflect the scaling change. Before diving into the approach let’s just have a quick look what Fabric.js is − What is Fabric.js? Fabric.js is a JavaScript library for creating and manipulating HTML5 canvas elements. It allows developers to create and manipulate canvas elements using an object-oriented API, making it easy to add, edit, and delete shapes, text, images, ... Read More

How to add default horizontal scaling to a canvas-type text with JavaScript?

AmitDiwan
Updated on 06-Feb-2023 12:30:31

221 Views

We can add default horizontal scaling to a canvas-type text by accessing the canvas context and setting the scale property to a specific value. This can be done by calling the context's scale method and passing in the desired value for the horizontal scaling. By doing this, all text drawn on the canvas will have the default horizontal scaling applied to it. HTML Canvas HTML canvas is a 2D drawing surface that can be used to create dynamic and interactive graphics, charts, and animations on web pages. It is an HTML element that allows developers to draw graphics using JavaScript. ... Read More

How to add content in section using jQuery/JavaScript?

AmitDiwan
Updated on 06-Feb-2023 12:23:53

1K+ Views

We can use jQuery's 'append' or 'prepend' method to add content to the section of a website. This can be done by selecting the element using jQuery's 'selector' method and then using the appropriate method to add the desired content. Additionally, we can also use JavaScript's 'innerHTML' property to add content to the section. There are quite some ways of adding content to head tag programmatically. Today we are going to discuss 3 of them − Using jQuery's .append() method − Using JavaScript's document.createElement() method − Using JavaScript's insertAdjacentHTML() method − Using these 3 ways ... Read More

How to Add Commas Between a List of Items Dynamically in JavaScript?

AmitDiwan
Updated on 06-Feb-2023 12:21:39

2K+ Views

We can use the CSS "::before" pseudo-element to dynamically add a comma before each list item, except for the first one. By targeting the list item and using the "content" property, we can insert a comma before the list item's content. Additionally, we can use the ":not(:first-child)" pseudo-class to ensure that only the non-first list items have the comma added. Consider we have the following HTML DOM: Item 1 Item 2 Item 3 Item 4 We will discuss two different approaches in this article that ... Read More

How to add code input in React.js?

AmitDiwan
Updated on 06-Feb-2023 12:12:18

475 Views

We can add code input in React.js by creating a component that renders an input field and handles user input. To do this, we can use the built-in React hooks such as useState to manage the input value and handle changes. Additionally, we can also use event handlers to handle user input and update the input value accordingly. Let us first understand what ReactJS and analyze the use of React Hook “useState” as it will be used inside the code. ReactJS React is a JavaScript library for building user interfaces. It makes it easy to create interactive UIs. Design simple ... Read More

How to add class to an element without addClass() method in jQuery?

AmitDiwan
Updated on 10-Apr-2023 14:49:19

6K+ Views

We can use the .attr() method to add a class to an element. This method can be used to set or get the value of an attribute on an HTML element. To add a class, we first select the element using a jQuery selector, and then call the .attr() method, passing in "class" as the first argument and the class name as the second argument. Let us first understand what jQuery is. jQuery is a JavaScript library that simplifies HTML document traversing, event handling, and animation. It allows for easy manipulation of the Document Object Model (DOM). It also provides ... Read More

Advertisements