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
Write a program to find the index of particular element in an array in javascript?
Finding the index of a particular element in an array is a common task in JavaScript. An array is an object that contains multiple values in a sequential order, with each element having a specific index position. 22 45 67 89 12 0 1 2 3 4 Array Elements Index ...
Read MoreJavaScript program to decrement a date by 1 day
JavaScript provides several methods to manipulate dates. To decrement a date by 1 day, we can use the setDate() and getDate() methods together. Syntax date.setDate(date.getDate() - 1); Parameters date.getDate() - Returns the current day of the month (1-31) date.setDate() - Sets the day of the month for the date object Example: Basic Date Decrement Decrement Date by 1 Day body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; ...
Read MoreImplementing Linear Search in JavaScript
Linear search is a simple algorithm that sequentially checks each element in an array until the target element is found or the end of the array is reached. It has a time complexity of O(n) in the worst case. How Linear Search Works Linear Search Process Array: [1, 19, 5, 11, 22, 55] Target: 22 1 i=0 19 i=1 ...
Read MoreRecursion in array to find odd numbers and push to new variable JavaScript
We are required to write a recursive function, say pushRecursively(), which takes in an array of numbers and returns an object containing odd and even properties where odd is an array of odd numbers from input array and even an array of even numbers from input array. This has to be done using recursion and no type of loop method should be used. Syntax const pushRecursively = (arr, len = 0, odd = [], even = []) => { // Base case: if we've processed all elements if (len ...
Read MoreHow to set text in tag with JavaScript?
In JavaScript, you can set text in HTML tags using various methods. This tutorial shows different approaches including jQuery and vanilla JavaScript. Using jQuery .html() Method First, create a element with an ID attribute: Replace This strong tag Then use jQuery to set the text content: $(document).ready(function(){ $("#strongDemo").html("Actual value of 5+10 is 15....."); }); Complete jQuery Example Set Text in Tag ...
Read MoreHow to list down all the cookies by name using JavaScript?
To list all cookies by name in JavaScript, you access the document.cookie property, split it into individual cookie pairs, and extract the name-value pairs from each cookie. How document.cookie Works The document.cookie property returns all cookies as a single string, with each cookie separated by semicolons. For example: "name1=value1; name2=value2; name3=value3". Method 1: Basic Cookie Listing Here's a simple approach to list all cookies by splitting the cookie string: function ReadCookie() { ...
Read MoreHow to draw a star in HTML5 SVG?
SVG stands for Scalable Vector Graphics and is a language for describing 2D-graphics and graphical applications in XML. Most web browsers can display SVG just like they can display PNG, GIF, and JPG. To draw a star in HTML5 SVG, we use the element. The key is to set the correct x and y coordinates for each point of the star, alternating between outer points (tips) and inner points (valleys). 5-Point Star using SVG Polygon ...
Read MoreWhat are Complex Data types in JavaScript?
In this tutorial, we will learn about complex data types in JavaScript. JavaScript has multiple built-in data types to store data in different formats. The data types of JavaScript can be divided into two groups: primitive data types and non-primitive data types. Number, String, Boolean, Undefined and Null are primitive data types, whereas Array and Object are non-primitive data types. The typeof operator is used to identify data types. The primitive data types are simple and easy to use. In contrast, the non-primitive data types (Array and Object) are relatively more complex than primitive data types, so the ...
Read MoreHow to add rows to a table using JavaScript DOM?
We will learn how to add a row to a table using JavaScript DOM. To achieve this, we have multiple methods. Some of them are the following. Using the insertRow() method By creating the new Element Using the insertRow() Method The insertRow() method is used to insert a new row at a specified position in the table. It creates a new element and inserts it into the table. This takes a number as a parameter that specifies the position of the table. If we do not pass any ...
Read MoreHow to set the color of the top border with JavaScript?
In this tutorial, we will learn how to set the color of the top border with JavaScript. The HTML element's outline is called the border. The border of an element can have multiple colors on each side. Different properties and methods are used to color each side of the border. To set the color of the top border with JavaScript, we have different ways − Using the style.borderTopColor Property Using the style.borderColor Property Using the style.borderTopColor Property The style.borderTopColor property of an element in JavaScript is used to ...
Read More