In JavaScript, comparing arrays directly with == or === compares references, not values. To check if two arrays contain the same values (regardless of order), we need custom comparison logic. The Problem with Direct Comparison var firstArray = [100, 200, 400]; var secondArray = [400, 100, 200]; console.log(firstArray === secondArray); // false console.log([1, 2] === [1, 2]); // false - different objects false false Using Sort and Compare Method The most reliable approach is to sort both arrays and compare ... Read More
We are required to write a JavaScript function that takes in three unsorted numbers and returns the middlemost of them using minimum number of comparisons. For example: If the numbers are − 34, 45, 12 Then our function should return the following − 34 Algorithm Explanation The algorithm uses mathematical differences to determine the middle element without explicit sorting. By calculating differences between pairs and checking their signs, we can identify the middle value efficiently. Example Following is the code − const num1 = 34; const ... Read More
Firefox web browser is widely used and loved by many users around the world. You can easily change the Firefox Browser theme to customize its appearance and make it look more awesome. Let's see how to reach the Firefox theme section and change the theme: Step 1: Open Firefox Menu Go to the Firefox browser menu by clicking the three horizontal lines (hamburger menu) in the top-right corner. From the dropdown menu, click on "Add-ons and themes": ... Read More
We use the cookie property of the document object to show the name/value pairs of cookies in a document with JavaScript. The document object, part of the DOM, corresponds to the current web page that the browser has loaded. It contains all the information about the condition of the browser as well as the web page. A server serves requests when a connection is set up and forgets everything about the user as soon as the connection is closed. This posed a nasty problem of bad user experience to the community. A cookie resolves this problem by storing small ... Read More
In this tutorial, we will learn how to display an HTML element using JavaScript. HTML elements are the components that make up an HTML format file. These components are in charge of constructing web pages and defining their content. In HTML, an element typically consists of a start tag, content, and a closing tag. Some HTML elements are − Starting Tag Content Ending Tag ... Read More
The user-scalable=no viewport meta tag prevents users from zooming on mobile devices. While it creates app-like experiences, it raises important accessibility concerns that developers must consider. What is user-scalable=no? The user-scalable property is part of the viewport meta tag that controls whether users can zoom in and out on mobile devices. When to Use user-scalable=no Consider using user-scalable=no only when creating web applications that need to mimic native mobile app behavior: App-like Interface ... Read More
The table-layout property controls how a browser calculates column widths in HTML tables. This property significantly affects rendering performance and layout behavior, especially with large tables or variable content. Syntax table-layout: auto | fixed | inherit; Property Values Value Description Performance auto Browser calculates widths based on cell content (default) Slower - requires content analysis fixed Uses first row to determine column widths Faster - renders immediately inherit Inherits value from parent element Depends on inherited value Example: Comparing auto vs fixed ... Read More
The buffer property of the DataView represents the ArrayBuffer of the current DataView. This property provides access to the underlying buffer that the DataView is viewing. Syntax dataView.buffer Return Value Returns the ArrayBuffer that was used to create the DataView instance. Example The following example demonstrates how to access the underlying ArrayBuffer through the buffer property: JavaScript Example var arrayBuffer = new ArrayBuffer(156); ... Read More
The logical NOT operator (!) is a unary operator that inverts boolean values. It returns true for falsy values and false for truthy values. Syntax !expression How It Works The NOT operator first converts the operand to a boolean value, then returns its opposite: If the operand is truthy, it returns false If the operand is falsy, it returns true Example with Boolean Values document.getElementById("boolean-demo").innerHTML = "!true = " + !true ... Read More
JavaScript provides a navigator object that contains information about the browser. To get the application name and version information, the navigator object provides navigator.appName and navigator.appVersion properties respectively. Application Name of the Browser The navigator.appName property returns the application name of the browser. However, due to historical reasons, most modern browsers (Chrome, Firefox, Safari, Edge) return "Netscape" regardless of their actual name. Example document.write("Application Name: " + navigator.appName); Output Application Name: Netscape Browser Version Information The navigator.appVersion property provides ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Economics & Finance