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 by Shubham Vora
Page 30 of 80
How to set the padding of an element with JavaScript?
In this tutorial, we will look at the methods to set the padding of an element with JavaScript. Padding can be termed as the space between an element's content and its border, whereas margin adds space around the edge. The padding property in JavaScript allows you to control this internal spacing dynamically. Understanding CSS Padding Values Before diving into JavaScript implementation, let's understand how padding values work: padding: 10px; Sets 10px padding to all four sides (top, right, bottom, left) padding: 10px 20px; Sets 10px to top/bottom, 20px to ...
Read MoreHow can I round down a number in JavaScript?
This tutorial teaches us to round down a number in JavaScript. The meaning of the round-down number is "returning the integer which is equal to or less than the current float number". For example, if we round down the number 9.99, we get 9 as an output, and in the same way, for 8.01 we get 8 as an output. In simple terms, if you represent your current number in the number line, you must return the nearest integer that resides on the left side of the current number. In this tutorial, we will take a look at ...
Read MoreHow to layout table cells, rows, and columns with JavaScript?
In this tutorial, we will learn how to lay out table cells, rows, and columns with JavaScript. We can construct and edit DOM (Document Object Model) elements using JavaScript. There are two ways to add HTML components, such as tables, to an HTML document. The first is to include the HTML table tag directly into our HTML webpage, and the second is to create the full table within our JavaScript code. The second method is the most commonly used for building and adding tables to the DOM. The tr abbreviation refers to the table row. This reflects the ...
Read MoreCan we make print button without JavaScript?
In this tutorial, we will learn to make a print button without writing separate JavaScript files. Most websites have print functionality that opens the browser's print dialog when clicked. While HTML doesn't have a built-in print method, we can use the window.print() method directly in HTML attributes. This allows us to create print functionality without external JavaScript files. Syntax The basic syntax for invoking the print method: window.print(); // Opens browser's print dialog Using the onClick Event We can call window.print() directly in HTML using the onClick event attribute. Syntax ...
Read MoreHow do I print Unicode characters in the console using JavaScript?
In this article, we will learn how to print Unicode characters in the console using JavaScript. Unicode assigns a unique number (code point) to each character, enabling consistent representation across different platforms and languages. Unicode is a universal character encoding standard that includes letters from most writing systems, punctuation marks, mathematical symbols, technical symbols, arrows, emoji, and other symbols. JavaScript provides several ways to work with Unicode characters in strings and console output. Using Escape Sequences JavaScript supports Unicode escape sequences to represent characters using their code point numbers. The most common format uses \u followed by ...
Read MoreHow to clear all cookies with JavaScript?
In this tutorial, we will learn to clear all cookies using JavaScript. Cookies are text data stored in the browser that help websites remember user information like usernames, authentication tokens, and preferences. When a user visits a webpage for the first time, it retrieves user information from the server and stores it as cookies in the browser. On subsequent visits, the webpage can access this stored data instead of making server requests, making the application faster and more efficient. Modern browsers typically allow cookies up to 4KB in size, with limits on the total number: Chrome allows around ...
Read MoreHow does JavaScript .prototype work?
In JavaScript, every function has a prototype property that serves as a template for creating objects. Understanding prototypes is essential for mastering JavaScript's object-oriented programming capabilities and inheritance patterns. What is a Prototype? A prototype is an object that exists on every function in JavaScript. When you create objects using constructor functions, they inherit properties and methods from the function's prototype. This enables code reusability and efficient memory usage. Consider creating multiple objects with similar properties: Basic Object Creation Creating Objects Without Prototype ...
Read MoreSmart / self-overwriting / lazy getters in javaScript?
In this tutorial, let us discuss the smart, self-overwriting, or lazy-getters in JavaScript. A getter binds the property of an object to a function, but the getter will not calculate the property value until we access it. Smart or lazy getters are a special pattern where the getter replaces itself after the first computation, avoiding recalculation and improving performance. The getter helps when we need to get some dynamic value without an explicit call. Smart getters are particularly useful for expensive operations that should only run once. Syntax { get prop() {} } { get ...
Read MoreHow can I Execute JavaScript at the Command Prompt?
To execute JavaScript at the command prompt, you can use several methods depending on your environment. This article covers three practical approaches: running JavaScript files through Node.js, executing code directly in the Node.js REPL, and using the browser console for quick testing. In this article, we'll explore how to execute JavaScript at the command prompt using different methods. Methods to Run JavaScript at Command Line Here are three methods to execute JavaScript at the command prompt, each with detailed explanations and examples: Running JavaScript Files with Node.js ...
Read MoreHow to preserve variables in a JavaScript closure function?
In this tutorial, we will look at the method to preserve variables in a JavaScript closure function. What is a closure function? A closure function gives access to the scope of an outer function from an inner function. It also allows private variables. Closure variables are stored in stack and heap. When a function is created, closure is also created. Closure remembers external things used in it. Closures are the primary mechanism for data privacy. One drawback is that the variables used are not garbage collected. Overuse of closure functions will damage the system due to redundant ...
Read More