Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Web Development Articles
Page 103 of 801
How to draw Regular Polygon in TypeScript?
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 MoreObject - Oriented Terms Supported by TypeScript
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 MoreHow is Declaration Merging done in TypeScript?
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 MoreHow to compile few typescript files to single output js-file?
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 MoreHow to Create a Basic Empty HTML Canvas?
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 MoreHow to create a Hidden Header using Google AMP Amp-Accordion?
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 MoreValidating a power JavaScript
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 MoreSplit array entries to form object in JavaScript
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 MoreSort Array of objects by two properties in JavaScript
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 MoreMerging sorted arrays together JavaScript
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