Web Development Articles

Page 103 of 801

How to draw Regular Polygon in TypeScript?

Mohit Panchasara
Mohit Panchasara
Updated on 21-Aug-2023 730 Views

Regular polygons, such as squares, triangles, and hexagons, are fundamental shapes used in various applications and graphics. Drawing regular polygons programmatically can be useful in TypeScript, allowing you to create geometric shapes dynamically. In this tutorial, we will explore how to draw regular polygons in TypeScript by leveraging basic mathematical principles and the HTML5 canvas element. Syntax function drawRegularPolygon(ctx: CanvasRenderingContext2D, n: number, x: number, y: number, r: number): void { const angle = (Math.PI * 2) / n; ctx.beginPath(); ctx.moveTo(x + r, y); for (let i = 1; i

Read More

Object - Oriented Terms Supported by TypeScript

Mohit Panchasara
Mohit Panchasara
Updated on 21-Aug-2023 2K+ Views

Object-oriented programming (OOP) is a popular programming paradigm that has been widely adopted in the software development industry. OOP is based on the concept of objects, which are instances of classes that encapsulate data and behaviour. TypeScript, a statically typed superset of JavaScript, is designed to support the development of large-scale applications and is also an object-oriented programming language. In this article, we will explore the object-oriented terms supported by TypeScript. Below we discuss various object-oriented terms supported by TypeScript. Class In TypeScript, a class is a blueprint for creating objects that define a set of properties and methods that ...

Read More

How is Declaration Merging done in TypeScript?

Mohit Panchasara
Mohit Panchasara
Updated on 21-Aug-2023 1K+ Views

Introduction TypeScript offers powerful features that enhance JavaScript development. One such feature is declaration merging, which allows developers to combine multiple declarations of the same entity into a single definition. This tutorial will introduce you to the concept of declaration merging in TypeScript and provide examples to help you understand its practical implementation. Declaration Merging Basics Declaration merging in TypeScript enables the compiler to merge multiple declarations for the same entity, such as interfaces, functions, classes, or enums. By merging declarations, you can extend existing types and add new properties, methods, or functionality. Let's explore the scenarios where declaration merging ...

Read More

How to compile few typescript files to single output js-file?

Mohit Panchasara
Mohit Panchasara
Updated on 21-Aug-2023 5K+ Views

TypeScript is a strongly typed superset of JavaScript that compiles to plain JavaScript. TypeScript adds static type-checking, classes, and interfaces to the language, making writing and maintaining large-scale applications easier. TypeScript files are compiled into JavaScript files that can be run in any browser or server that supports JavaScript. This article will look at how to compile multiple TypeScript files into a single output js-file. We will start by looking at how to use the TypeScript compiler to compile multiple TypeScript files and then see how to use Webpack to bundle multiple TypeScript files into a single JavaScript file. Compiling ...

Read More

How to Create a Basic Empty HTML Canvas?

Jaisshree
Jaisshree
Updated on 21-Aug-2023 453 Views

HTML canvas is a sophisticated web−based tool for producing interactive and dynamic visuals. Developers may use JavaScript to edit the canvas element to create animations, games, data visualizations, and more. There are alternative methods to create empty HTML Canvas − Fabric.js is a simple JavaScript library for working with the HTML5 canvas element. It offers an object−oriented API for creating and modifying canvas elements. Using Konva.js: Another powerful JavaScript library that provides an easy−to−use API for creating and manipulating canvas elements is Konva.js. It is built on top of the HTML5 canvas element and offers a comprehensive set of tools ...

Read More

How to create a Hidden Header using Google AMP Amp-Accordion?

Jaisshree
Jaisshree
Updated on 21-Aug-2023 185 Views

Google AMP (Accelerated Mobile Pages) is an open−source framework designed to create fast−loading and mobile−friendly web pages, while amp−accordion is a component in the AMP library that allows for collapsible content sections on a web page. Google offers the Accelerated Mobile Pages (AMP) framework allowing you to make hidden content that the user can toggle open and closed. Algorithm Declare a new HTML5 document using the declaration at the beginning of the file. Inside the element, add the ⚡ attribute to indicate that this is an AMP HTML document. Inside the element, add the meta element with the ...

Read More

Validating a power JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-Aug-2023 231 Views

In this problem we have to validate that a given number is a power of n. If the given number is power of n then it should return the true value of it otherwise it should return false. To check this kind of validation we generally use arithmetic operators like Modulus - %, Division - /, comparison operators like less than < or greater than >. Lets understand this problem with an example. True value: N = 27 So 33 = 27 False Value: N = 28 So 33 != ...

Read More

Split array entries to form object in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-Aug-2023 550 Views

The problem statement is saying that we have to find a solution for a given array and split it to form an object with a key-value pair in javascript. Understand the problem In simple terms we have to convert a given array into an object. There are several methods present in javascript to convert an array into an object. We will use and code each of them one by one. Using reduce() and split() methods In this method we will use reduce and split functions of javascript. Algorithm The algorithm here discusses ...

Read More

Sort Array of objects by two properties in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-Aug-2023 3K+ Views

Given problem says to sort the given array of objects by two properties and create a program in javascript. Understanding the problem Let's have a deep understanding of the problem statement. You will be given an array of objects with key and value. As per the problem statement we need a sorted form of that array. To implement this problem we will first sort the first column of array and then second column of array. And then again arrange it in sorted form. As we understand arrays are basic data structures in computer science. Array can also ...

Read More

Merging sorted arrays together JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 18-Aug-2023 947 Views

Merging the sorted arrays together in javascript can be done using the sorting techniques available in data structures. In this problem we will be given two sorted arrays and we have to merge them. After merging them, return a single array which is also in a sorted form. For solving this problem we will use greedy approach. What are Sorted Arrays ? In javascript arrays are the collection of similar data types and we can resize the array in run time. Sorted arrays are sequential forms of items of an array. Their order should be ...

Read More
Showing 1021–1030 of 8,006 articles
« Prev 1 101 102 103 104 105 801 Next »
Advertisements