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 debug JavaScript in Visual Studio?
To debug JavaScript in Visual Studio, you need to configure both Visual Studio and Internet Explorer settings. This guide covers the essential steps for debugging client-side JavaScript applications. Prerequisites Before debugging JavaScript in Visual Studio, ensure you have: Visual Studio installed with web development workload A web project containing JavaScript files Internet Explorer available (Visual Studio's default debugging browser) Setting Up Visual Studio Project Follow these steps to configure your Visual Studio project for JavaScript debugging: Open Visual Studio ...
Read MoreProper use of flex properties when nesting flex containers
A flex container is always the parent and a flex item is always the child. The scope of a flex formatting context is limited to a parent/child relationship. Descendants of a flex container beyond the children are not part of flex layout and will not accept flex properties. There are certain flex properties that apply only to flex containers: justify-content flex-wrap flex-direction align-items align-content There are certain flex properties that apply only to flex items: ...
Read MoreRemove a FileList item from a multiple "input:file" in HTML5
When working with HTML5 file inputs, you cannot directly modify the FileList object returned by input.files. The FileList is read-only, so removing items requires converting it to an array first. The Problem The FileList object from file inputs is immutable: Show Files Try Direct Removal function showFiles() { const files = document.getElementById('fileInput').files; document.getElementById('output').innerHTML = 'Files selected: ' + files.length; } function tryDirectRemoval() { const files = document.getElementById('fileInput').files; try { ...
Read MoreNumber of elements a particular tag contains in JavaScript?
In this article we are going to learn about counting the number of child elements a particular tag contains in JavaScript with suitable examples. There are two main approaches to count child elements in JavaScript. You can use the childElementCount property to count direct child elements, or use the length property with methods like getElementsByClassName() to count elements by class name. Let's explore both methods with practical examples to understand how to count elements effectively. Using the childElementCount Property The childElementCount property returns the number of direct child elements within a specific parent element. It only ...
Read MoreFunction returning another function in JavaScript
In JavaScript, functions can be assigned to variables, passed as arguments to other functions, and returned from other functions. This behavior allows us to create higher-order functions (HOFs), which are functions that return other functions. These higher-order functions enable powerful patterns like callbacks, function memoization, and data transformation. In this article, we will learn about functions returning other functions in JavaScript and explore practical examples of their usage. Basic Function Returning Function A function that returns another function creates a closure, where the inner function has access to the outer function's variables: function createGreeter(greeting) { ...
Read MoreDetect the ENTER key in a text input field with JavaScript
Detecting the ENTER key in a text input field is a common requirement in web development. You can accomplish this using JavaScript event listeners and checking for the specific key code or key value. HTML Setup First, let's create a simple text input field: Method 1: Using keyCode (Legacy) The traditional approach uses keyCode property with value 13 for the ENTER key: ENTER Key Detection ...
Read MoreFinding lunar sum of Numbers - JavaScript
The concept of lunar sum says that the sum of two numbers is calculated by taking the larger digit from each corresponding position, instead of adding them together. How Lunar Sum Works For each digit position, we compare the digits from both numbers and take the maximum value. Let's see how this works with an example: a = 879 and b = 768 Position-wise comparison: Position 1: max(8, 7) = 8 Position 2: max(7, 6) = 7 Position 3: max(9, 8) = 9 Lunar Sum: 879 Implementation ...
Read MoreHow to reverse a portion of an array in JavaScript?
We are required to write a JavaScript function that takes in an array, a start index and an end index. The function should reverse the portion of the array between the start index and end index. For example, if the array is: const arr = [2, 6, 5, 8, 3, 5, 2, 6, 7]; And the start index and end index are 3, 7 respectively, then the array should be reversed to: const output = [2, 6, 5, 2, 5, 3, 8, 6, 7]; Using Array Splice Method This approach ...
Read MoreHow to convert a Unix timestamp to time in JavaScript?
To convert a Unix timestamp to time in JavaScript, you need to multiply the timestamp by 1000 (since Unix timestamps are in seconds, but JavaScript Date expects milliseconds) and then use Date methods to extract time components. What is a Unix Timestamp? A Unix timestamp represents the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC. JavaScript's Date constructor expects milliseconds, so we multiply by 1000. Example JavaScript Dates ...
Read MoreHow to debug obfuscated JavaScript?
Debugging obfuscated JavaScript code requires unminifying and formatting the compressed code to make it readable. Obfuscated code is deliberately made difficult to understand by removing whitespace, shortening variable names, and sometimes encoding strings. What is Obfuscated JavaScript? Obfuscated JavaScript is code that has been intentionally made difficult to read and understand. It typically looks like this: var _0x1234=['hello', 'world'];function _0x5678(){console.log(_0x1234[0]+' '+_0x1234[1]);} Method 1: Using Online JavaScript Formatter The easiest way to debug obfuscated code is using an online formatter. Go to the TutorialsPoint JavaScript Formatter: Paste your obfuscated JavaScript code in ...
Read More