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 know the browser language and browser platform in JavaScript?
In this article we are going to discuss how to know the browser language and browser platform with the help of examples in JavaScript To know the various properties of the browser, JavaScript provides the Navigator object. The Navigator object has several properties, which include - connection, credentials, cookies, geolocation, language, platform, etc. We are concerned with Navigator.language and Navigator.platform to know the language and platform of the browser. Let us discuss about them in detail. Navigator.language The read-only Navigator.language property returns a string that represents the browser UI language. It returns a string that contains the ...
Read MoreHow to Create GUID / UUID in JavaScript?
A Globally Unique Identifier (GUID) or Universally Unique Identifier (UUID) is a 128-bit value used as a unique identifier in software development. It's typically represented as a 32-character hexadecimal string with hyphens, like: de305d84-75c4-431d-acc2-eb6b0e5f6014. Here are several JavaScript methods to generate GUIDs/UUIDs. Using Random Number Generation The most common approach uses Math.random() to generate a UUID v4 format: function generate_uuidv4() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var uuid = Math.random() * 16 | 0, v = c == 'x' ? uuid : (uuid & 0x3 ...
Read MoreJavaScript focus a particular element with div class, not div id declaration?
In this article, we will learn to focus on a particular element with a div class in JavaScript. In JavaScript, setting focus on an element is commonly done using the focus() method, which works with elements selected by class name. What is the focus() method? The focus() method in JavaScript is used to bring a specific element into focus. This means the element becomes active, allowing the user to interact with it, such as typing in an input field or highlighting a section of the webpage. Syntax element.focus(); Here, the element is the ...
Read MoreStatic Properties in JavaScript
Static properties in JavaScript belong to the class itself rather than its instances. They can be accessed directly on the class without creating objects, making them useful for storing class-level data like constants or shared values. Syntax // Function constructor approach function ClassName(params) { // instance properties } ClassName.staticProperty = value; // ES6 class approach class ClassName { static staticProperty = value; } Example: Static Properties with Function Constructor ...
Read MoreCompletely removing duplicate items from an array in JavaScript
We are required to write a function that takes in an array and returns a new array that have all duplicate values removed from it. The values that appeared more than once in the original array should not even appear for once in the new array. For example, if the input is: const arr = [23, 545, 43, 232, 32, 43, 23, 43]; The output should be: [545, 232, 32] Understanding indexOf() vs lastIndexOf() Array.prototype.indexOf() → Returns the index of first occurrence of searched ...
Read MoreGet the longest and shortest string in an array JavaScript
We have an array of string literals like this: const arr = ['Some', 'random', 'words', 'that', 'actually', 'form', 'a', 'sentence.']; We need to write a function that returns the longest and shortest word from this array. We will use the Array.prototype.reduce() method to keep track of the longest and shortest word during iteration. Using Array.reduce() Method The reduce() method processes each element and maintains an accumulator object containing both the longest and shortest strings found so far: const arr = ['Some', 'random', 'words', 'that', 'actually', 'form', 'a', 'sentence.']; const findWords = ...
Read MoreHow to convert Binary to Decimal in JavaScript?
In this tutorial, we will learn to convert binary to decimal in JavaScript. A binary number is a string of '0' and '1' digits, representing numbers in base 2 format used in digital electronics. Here are two different methods to convert binary numbers to decimal: Using the parseInt() Method The parseInt() method can extract numbers from strings and accepts a base parameter, making it perfect for binary conversion. Syntax let binary = "0101"; let decimal = parseInt(binary, 2); Parameters binary − The binary number as a string base − The ...
Read MoreHow to set the page-break behavior after an element with JavaScript?
Use the pageBreakAfter property in JavaScript to control page-break behavior after an element. This property is essential for formatting printed documents and print previews. Note: Changes are only visible when printing the page or viewing print preview (Ctrl+P). Syntax element.style.pageBreakAfter = "value"; Property Values Value Description auto Default - automatic page breaks always Forces page break after element avoid Avoids page break after element left Forces page break to left page right Forces page break to right page ...
Read MoreHow can I make a div with irregular shapes with CSS3 and HTM5?
With CSS3, you can create various shapes including rectangles, triangles, circles, and more complex irregular shapes using properties like border-radius, transform, and clip-path. Basic Shapes Rectangle A simple rectangle is created using width and height properties: #rectangle { width: 300px; height: 150px; background: blue; } Triangle Triangles are created using border properties with transparent sides: #triangle { width: 0; height: 0; ...
Read MoreBootstrap Labels
Labels are great for offering counts, tips, or other markups for pages. Bootstrap provides the .label class to create inline labels that complement text content. Basic Label Syntax Use the .label class along with contextual classes to create different styled labels: Default Primary Success Example Here's a complete example showing labels used with headings to display counts: Bootstrap Labels Example ...
Read More