Shubham Vora

Shubham Vora

793 Articles Published

Articles by Shubham Vora

Page 3 of 80

How to throw an error when using a property of an object?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 715 Views

In JavaScript, objects contain properties in key-value format. When accessing non-existent properties, JavaScript returns undefined instead of throwing an error. However, you can implement custom error handling to throw errors when invalid properties are accessed. Default Behavior: Accessing Non-existent Properties By default, JavaScript returns undefined for non-existent properties: Default behavior when accessing object properties let content = document.getElementById('content'); let object = { ...

Read More

How do you receive server-sent event notifications in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 861 Views

Server-sent events (SSE) provide a unidirectional communication channel between server and client. When you only need to send data from server to client, SSE offers an efficient alternative to polling or WebSockets. Server-sent events work by establishing a persistent connection where the server pushes data to the client. The server can be any backend technology like Node.js, PHP, or Ruby. When the server sends data, a 'message' event fires on the client-side, which can be handled with event listeners. How Server-Sent Events Work The process involves three main steps: Client establishes connection using ...

Read More

How to place cursor position at end of text in text input field using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 12K+ Views

In HTML, the input field is used to take input from the users. Sometimes, we require to take string or long text messages in the input. In these scenarios, users may need to go to the end of the input field to add more content or message. So, we should set up something such that users can click the button, can go to the end of the input field. In this tutorial, we will learn to use JavaScript to place the cursor position at the end of the text in the input field. Using the setSelectionRange() method The ...

Read More

How to play a notification sound on websites?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 8K+ Views

Nowadays, web development continues to evolve and find new ways to improve the user experience. One way to improve the user's experience is by adding notifications to the website to notify users of any event. Before we start with the tutorial, let's understand why we need notifications with sounds on the website. Why Add Notification Sounds? As we said above, notification is used to enhance the user experience. We can use it to notify users for a task, such as when users completes the form submission, get a message in the chat app, for reminders, etc. ...

Read More

How to install yup in react native in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 5K+ Views

Yup is a popular JavaScript schema validation library that integrates seamlessly with React Native applications. It provides a simple and powerful way to validate form data by defining validation schemas with various rules for different field types. Installation Install Yup in your React Native project using npm or yarn: npm install yup Or using Yarn: yarn add yup Basic Syntax Create validation schemas using Yup's chainable API: import * as Yup from 'yup'; const schema = Yup.object().shape({ fieldName: Yup.string().required("This field is required"), ...

Read More

Javascript Program to Check if two numbers are bit rotations of each other or not

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 297 Views

Problem Statement − We have given two integer numbers and need to check whether the two numbers are bit rotations of each other. In JavaScript, every integer is a 32-bit binary number which is a representation of 0 and 1. Here, we need to check if we rotate the 32-bit string of the first number; we can achieve the 32-bit string of the second number or not out of a total of 32 rotations of the first number. What are Bit Rotations? Bit rotation means moving bits from one end to another. For example, if we rotate ...

Read More

Text to Voice conversion using Web Speech API of Google Chrome

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 1K+ Views

Nowadays, audiobooks are more preferred by readers over traditional books as they can absorb knowledge while multitasking. Many websites also include audio versions of articles, allowing users to listen instead of reading. To convert text to speech, we use the Web Speech API available in modern browsers. In this tutorial, we will learn how to use the Web Speech API to convert text to voice with practical examples. Syntax Users can follow the syntax below to use the Web Speech API for text-to-speech conversion. var synth = window.speechSynthesis; var speechObj = new SpeechSynthesisUtterance(text); synth.speak(speechObj); ...

Read More

How to read all spans of a div dynamically?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 1K+ Views

One HTML element can contain multiple nested HTML elements while creating web pages. In some cases, developers may require to read the particular HTML elements of one HTML element. In our case, we require to read all span elements of the div element and extract the content of them. In this tutorial, we will learn to read the content of all spans of a div element using JavaScript and again append it to the web page in the formatted way. Syntax Users can follow the syntax below to read all spans of a div element dynamically using ...

Read More

What is tree shaking in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 386 Views

What is Tree Shaking? Tree shaking is a technique used in modern JavaScript development to eliminate unused or "dead" code from your application bundle. The term comes from the metaphor of shaking a tree to remove dead leaves and branches, keeping only what's alive and necessary. This process analyzes your code during the build process and removes any imported functions, variables, or modules that are never actually used in your application, resulting in a smaller, more efficient bundle. Why Do We Need Tree Shaking? Tree shaking provides several key benefits for web applications: Reduced ...

Read More

How to remove “disabled” attribute from HTML input element using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 4K+ Views

In HTML, we can use input elements to take input from the users by creating a form or in any other way. There are different types of input elements, such as checkboxes, radio buttons, text, numbers, etc. We can use the 'disabled' property with every element to disable the input field and stop users from interacting with the input element. In some cases, we require to add and remove the disabled attribute using JavaScript. For example, we want to take the pan card numbers of the users whose age is greater than 18. So, we require to enable the ...

Read More
Showing 21–30 of 793 articles
« Prev 1 2 3 4 5 80 Next »
Advertisements