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
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to make controlling corners of Text transparent using FabricJS?
In this tutorial, we are going to learn how to make the controlling corners of Text transparent using FabricJS. We can display text on canvas by adding an instance of fabric.Text. Not only does it allow us to move, scale and change the dimensions of the text but it also provides additional functionality like text alignment, text decoration, line height which can be obtained by the properties textAlign, underline and lineHeight respectively. The transparentCorners property allows us to make the controlling corners of Text object transparent. Syntax new fabric.Text(text: String, { transparentCorners: Boolean }: Object) ...
Read MoreWorking with HTML5 Canvas Elements using Easel.js
The popularity of HTML5 Canvas elements is well-known, as they allow web developers to create animations, full-fledged applications, and interactive charts. However, working with canvas can be challenging, especially for developers coming from a Flash animation background. In this tutorial, we will explore the Easel.js library, which simplifies working with HTML5 Canvas elements. The syntax of Easel.js is similar to ActionScript and includes familiar features like Display List, Stage, and Graphics, making canvas development more accessible for Flash developers. Installing Easel.js The first step is to import Easel.js into your project. The easiest way is using the ...
Read MoreHow to create the previous and next buttons and non-working on the end positions using JavaScript?
We can create previous and next buttons that are disabled at their end positions using vanilla JavaScript. JavaScript allows us to control and manipulate DOM elements easily. Here, we will create navigation buttons and change an HTML element's content depending on which button is clicked. Example 1: Counter with Disabled States In this example, we will create "Next" and "Previous" buttons that increment and decrement a counter. The buttons will be disabled when they reach their extreme positions (0 for Previous and 5 for Next). Previous and Next Buttons with ...
Read MoreChanging positivity/negativity of Numbers in a list in JavaScript
We are required to write a JavaScript function that takes in an array of positive as well as negative Numbers and changes the positive numbers to corresponding negative numbers and the negative numbers to corresponding positive numbers in place. Example The code for this will be − const arr = [12, 5, 3, -1, 54, -43, -2, 34, -1, 4, -4]; const changeSign = arr => { arr.forEach((el, ind) => { arr[ind] *= -1; }); }; changeSign(arr); console.log(arr); ...
Read MoreHow to make a condition for event 'click' inside/outside for multiple divs - JavaScript?
In JavaScript, you can detect clicks inside or outside multiple divs using event listeners and the contains() method. This is useful for dropdowns, modals, or interactive UI components. The Problem When working with multiple divs, you need to determine if a click event occurred inside any of the target divs or outside all of them. This requires checking the event target against all div elements. Solution Using Event Delegation Add a single event listener to the document and check if the clicked element is contained within any target div: ...
Read MoreLoop through an index of an array to search for a certain letter in JavaScript
We need to write a JavaScript function that takes an array of strings and a single character, then returns true if the character exists in any string within the array, false otherwise. Problem Overview The function should search through each string in the array to find if the specified character exists anywhere. This is a common pattern for filtering or validation tasks. Example Implementation Here's how to implement this search functionality: const arr = ['first', 'second', 'third', 'last']; const searchForLetter = (arr = [], letter = '') => { ...
Read MoreEncrypting a string using Caesar Cipher in JavaScript
The Caesar Cipher algorithm is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example: With a left shift of 3, D would be replaced by A, E would become B, and so on. We need to write a JavaScript function that takes in a string to be encrypted as the first argument and a shift amount as the second argument. The shift amount can be a positive or ...
Read MoreJoining strings to form palindrome pairs in JavaScript
We are required to write a JavaScript function that takes in an array of strings as the only argument. The function is supposed to return an array of arrays of all the index pairs joining the strings at which yields a new palindrome string. For example, if the input to the function is: const arr = ['tab', 'cat', 'bat']; Then the output should be: [[0, 2], [2, 0]] Output Explanation Because both the strings 'battab' and 'tabbat' are palindromes when we join: arr[0] + arr[2] ...
Read MoreCreating a binary spiral array of specific size in JavaScript
We are required to write a JavaScript function that takes in a number n. Our function should construct and return an array of N * N order (2-D array), in which the 1s take all the spiralling positions starting from [0, 0] and all the 0s take non-spiralling positions. Therefore, for n = 5, the output will look like: [ [ 1, 1, 1, 1, 1 ], [ 0, 0, 0, 0, 1 ], [ 1, 1, 1, 0, 1 ], [ 1, 0, 0, 0, 1 ], ...
Read MoreDecipher.final() Method in Node.js
The decipher.final() method in Node.js is used to return the remaining decrypted data from a decipher object. It is part of the crypto module's Decipher class and must be called to complete the decryption process. Once called, the decipher object cannot be used to decrypt additional data. Syntax decipher.final([outputEncoding]) Parameters outputEncoding – Optional. The encoding format for the output. Possible values include 'utf8', 'hex', 'base64', etc. If not specified, a Buffer is returned. Return Value Returns a Buffer or string containing the final decrypted data, depending on whether outputEncoding is ...
Read More