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
Javascript Articles
Page 420 of 534
Inserting string at position x of another string using Javascript
In this article, you are going to learn how to insert a string at a position in another string. JavaScript does not provide a direct method to insert a string at a specific position. However, we can achieve this using various string methods like slice(), substr(), and array methods like join(). Using the slice() Method The slice() method extracts a section of a string and returns a new string without modifying the original string. Syntax String.slice(start, end) Parameters start − Required. The position from where to start ...
Read MoreConverting a string to a date in JavaScript
In this article, we are going to discuss how to convert a string value to a Date object in JavaScript. There are two ways to achieve this − Using the constructor of the Date class − This constructor accepts a string value representing the date value, converts it into a Date object, and returns the result. Using the Date.parse() method − Same as the Date constructor this method accepts a string value parses and returns the date value in the form of milliseconds. Let us see these solutions with examples − Using the Date() constructor ...
Read MoreJasmine.js comparing arrays
In Jasmine.js, arrays can be compared in two different ways depending on your testing needs: Reference equality - checking if two variables refer to the same array object in memory Content equality - checking if arrays contain the same elements, even if they are different objects Using toBe() for Reference Equality The toBe() matcher checks whether two arrays are the exact same object in memory. This is useful when you want to verify that two variables reference the same array instance. describe("Array Reference Equality", () => { ...
Read MoreHow to clone a js object except for one key in javascript?
In JavaScript, cloning an object except for one key means creating a copy of an object while excluding specific properties. This is a common requirement when you need to create modified versions of objects without mutating the original. There are several approaches to accomplish this, depending on whether you need a shallow or deep clone: Shallow Clone - Copies only the top-level properties Deep Clone - Recursively copies all nested objects and arrays Understanding Shallow vs Deep Cloning Shallow Clone A shallow clone copies the object's structure but not nested objects. Both the original ...
Read MoreObject literals vs constructors in JavaScript
Object literals and constructors are two fundamental ways to create objects in JavaScript. Object literals create singleton objects, while constructor functions can create multiple instances with shared behavior. Object Literal Notation Object literals use curly braces {} to define properties and methods directly. They are ideal for creating single-use objects or configuration objects. Object Literal Example const userDetails = { name: "Aman", ...
Read MoreJavaScript symbol.description property
The symbol.description property in JavaScript returns the description string of a Symbol. Unlike Symbol.toPrimitive, the description property provides access to the optional description passed when creating a Symbol. Syntax symbol.description Return Value Returns the description string of the Symbol, or undefined if no description was provided during Symbol creation. Example: Symbol with Description Symbol Description Example Click to display symbol description... Show Description function display() { const sym1 = Symbol('user-id'); const ...
Read MoreDebugging JavaScript using Firebug
Debugging is the systematic method of removing defects from code. While JavaScript is a powerful scripting language for web development, it lacks built-in debugging functionalities. Fortunately, Firebug, a web browser-based debugger for Firefox, provides excellent tools for debugging JavaScript code effectively. Firefox Browser with Firebug Web Page Content ...
Read MoreHow to change tabs on hover with CSS and JavaScript?
In this article, we will discuss how to change tabs on hover with CSS and JavaScript. Hover Tabs are an interactive UI pattern that allows users to switch between different content sections by simply hovering over tab buttons. When you move your cursor over a tab, its associated content is immediately displayed without requiring a click. This creates a smooth, responsive user experience where content changes dynamically as users explore different options. For example, in a product showcase, hovering over different category tabs could instantly display relevant products. How It Works The hover tab system combines ...
Read MoreHow to create a full screen overlay navigation menu with CSS and JavaScript?
In this article, we are going to discuss how to create a full-screen overlay navigation menu with CSS and JavaScript. Overlay in web applications is nothing but transposing one HTML element over another. We can overlay images, pages, text, etc. A full-screen overlay navigation provides an elegant way to display navigation links that cover the entire viewport when activated. There are three ways to create a full-screen overlay navigation bar which are listed below: From the left side From the top side No animation There ...
Read MoreHow to create an off-canvas menu with CSS and JavaScript?
An off-canvas menu is a sidebar navigation that slides in from the side of the screen when activated. This design pattern is popular in responsive web design as it saves screen space while providing easy access to navigation links. Off-canvas menus are particularly useful for mobile devices and websites with numerous navigation items that don't fit in a traditional horizontal navigation bar. They can slide from left-to-right or right-to-left, and often overlay or push the main content aside. HTML Structure First, create the HTML structure with a sidebar navigation and main content area: ...
Read More