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 310 of 534
Loop through a hash table using Javascript
Hash tables (also called hash maps) store key-value pairs and provide efficient lookup. To iterate through all entries, we need to traverse each chain in the underlying storage container since hash tables typically use chaining to handle collisions. Creating a forEach Method The forEach method loops over all key-value pairs in the hash table and executes a callback function for each pair. We iterate through each chain in the container and process every key-value pair. forEach(callback) { // For each chain in the hash table this.container.forEach(elem => { ...
Read MoreHow to convert Unicode values to characters in JavaScript?
In this tutorial, we will learn to convert Unicode values to characters in JavaScript. The Unicode values are the standard values for the character, and users can encode them to convert them into characters. For example, 'A' is a Unicode character whose value is 65 according to the ASCII (American standard code for information interchange) table. In the same way, all alphabets, numbers, and other characters have particular Unicode values. We will learn to identify the Unicode character from its values using JavaScript. Using the fromCharCode() Method In JavaScript, the String object contains the fromCharCode() method, which ...
Read MoreFor Hosts Locale how to convert a string to lowercase letters in JavaScript?
To convert a string to lowercase letters in JavaScript, use the toLocaleLowerCase() method. This method converts characters to lowercase according to the host's locale, making it ideal for international applications. Syntax string.toLocaleLowerCase([locale]) Parameters locale (optional): A string specifying the locale to use for conversion. If omitted, the host environment's current locale is used. Basic Example Here's how to use toLocaleLowerCase() to convert a string to lowercase: var str ...
Read MoreAtomics.isLockFree() function in JavaScript
The Atomics object in JavaScript provides atomic operations for use with SharedArrayBuffer objects in multi-threaded environments. The Atomics.isLockFree() method determines whether the JavaScript engine can perform atomic operations on a given byte size without using locks. This method helps optimize performance by checking if atomic operations are lock-free for specific data sizes, which is crucial for high-performance concurrent programming. Syntax Atomics.isLockFree(size) Parameters size: An integer representing the size in bytes. Valid values are typically 1, 2, 4, or 8 bytes corresponding to Int8, Int16, Int32, or BigInt64 array types. Return Value ...
Read MoreFind a form feed character with JavaScript RegExp.
Form feed character is a page breaking ASCII control character commonly used for page separators. When you want to insert a page break, text editors can use this form feed. It is defined as \f and has an ASCII code value of 12 or 0x0c. RegExp is an object that specifies the pattern used to perform search and replace operations on strings or for input validation. RegExp was introduced in ES1 and is fully supported by all browsers. Now, we will check how to find the form feed (\f) character in given text using RegExp. Syntax ...
Read MoreDataView.byteLength property in JavaScript
The byteLength property of the DataView represents the length of the current DataView in bytes. This property is read-only and returns the number of bytes from the start of the DataView to the end. Syntax Its syntax is as follows: dataView.byteLength Parameters This property takes no parameters as it's a read-only property, not a method. Return Value Returns a number representing the length of the DataView in bytes. Example 1: Basic Usage JavaScript Example ...
Read MoreFor the Hosts Locale how to convert a string to uppercase letters in JavaScript?
In this tutorial, we will learn how to convert a string to uppercase letters for the host's locale in JavaScript. While using a locale language to write for a website, we might have to convert the sentence from lowercase to uppercase without changing the structure of the string. Using the toLocaleUpperCase() Method In JavaScript, we use the toUpperCase() method as well as the toLocaleUpperCase() to change the letters of a string to uppercase. Although both methods give similar output, the toLocaleUpperCase() is used primarily for local languages and handles locale-specific character mappings correctly. Syntax We ...
Read MoreDataView.byteOffset property in JavaScript
The byteOffset property of the DataView represents the offset (in bytes) from the start of the underlying ArrayBuffer where the DataView begins. Syntax Its syntax is as follows: dataView.byteOffset Return Value Returns a number representing the byte offset of the DataView from the beginning of its ArrayBuffer. Example 1: Basic byteOffset When creating a DataView without specifying an offset, the byteOffset property returns 0: JavaScript DataView byteOffset Example ...
Read MoreWhat is the role of pageXOffset property in JavaScript?
The pageXOffset property returns the number of pixels the document has been scrolled horizontally from the left edge of the window. It's a read-only property of the window object used to track horizontal scroll position. Syntax let horizontalScroll = window.pageXOffset; Return Value Returns a number representing the horizontal scroll position in pixels. Returns 0 if the document hasn't been scrolled horizontally. Example: Basic Usage div { ...
Read MoreDataView.buffer property in JavaScript
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