Articles on Trending Technologies

Technical articles with clear explanations and examples

TypedArray.byteLength property in JavaScript

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 128 Views

The byteLength property of the TypedArray object represents the length of the TypedArray in bytes. It is a read-only property that returns the size of the underlying buffer used by the typed array. Syntax typedArray.byteLength Example: Basic Usage JavaScript Example var buffer = new ArrayBuffer(156); var float32 = new Float32Array(buffer); document.write("ByteLength: " + float32.byteLength); ...

Read More

How to calculate total time between a list of entries?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 232 Views

Let's say, we have an array that contains some data about the speed of a motor boat during upstreams and downstreams like this − Following is our sample array − const arr = [{ direction: 'upstream', velocity: 45 }, { direction: 'downstream', velocity: 15 }, { direction: 'downstream', velocity: 50 }, { direction: 'upstream', velocity: 35 }, { direction: 'downstream', velocity: 25 }, { ...

Read More

JavaScript Adding array name property to JSON object [ES5] and display in Console?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 238 Views

In JavaScript, you can add a JSON object to an array and assign it a property name for better organization. This is useful when you need to convert object data into array format while maintaining structure. Initial Object Setup Let's start with a sample customer object: var customerDetails = { "customerFirstName": "David", "customerLastName": "Miller", "customerAge": 21, "customerCountryName": "US" }; Adding Object to Array Using push() Create a new array and use the push() method to add the ...

Read More

How to use JavaScript to set cookies for a specific page only?

Abhishek Kumar
Abhishek Kumar
Updated on 15-Mar-2026 3K+ Views

We can set cookies for a specific page only using JavaScript. We use the path attribute of the document.cookie property to set the cookie on a specific webpage. Cookies are small text files (4 KB) that store important information such as username, email, session id, and other preferences that help customize the webpage for a particular user. The pathname property of the Window location returns a string containing the path of the current webpage. The path is basic information about where the current webpage is stored on the server. document.cookie Syntax The document.cookie property returns a list ...

Read More

How can I round a number to 1 decimal place in JavaScript?

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

In this tutorial, we will learn to round a number to a one decimal place in JavaScript. There are various needs to round the float numbers and show particular digits after the decimal point. In our case, we need to show only one digit after the decimal point. However, we will create a customizable function that can round off the number and show the particular number of digits after the decimal point at the end of this tutorial. This example lets users understand the fundamental need to round a number to a single decimal digit. Suppose you are ...

Read More

How to call a function in JavaScript?

Nancy Den
Nancy Den
Updated on 15-Mar-2026 1K+ Views

JavaScript allows us to write our own functions as well. To invoke a function somewhere later in the script, you would simply need to write the name of that function. Function Declaration Before calling a function, you need to declare it. Here's the basic syntax: function functionName() { // Code to execute } Calling a Function Once declared, you can call a function by writing its name followed by parentheses: function sayHello() ...

Read More

With JavaScript RegExp find a character except newline?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 299 Views

To find a character except for a newline, use the dot metacharacter . (period). The dot matches any single character except the newline character (). Syntax /./ // Matches any character except newline /.+/ // Matches one or more characters except newline /a.b/ // Matches 'a', any character, then 'b' Example JavaScript Regular Expression ...

Read More

Set the font style with CSS

radhakrishna
radhakrishna
Updated on 15-Mar-2026 219 Views

To set the font style, use the font-style property. This CSS property allows you to make text appear italic, normal, or oblique. Syntax font-style: normal | italic | oblique; Values normal - Default font style (upright text) italic - Slanted version of the font (if available) oblique - Artificially slanted text Example: Italic Font Style You can try to run the following code to set the font-style to italic with CSS: Font Style Example ...

Read More

TypedArray.byteOffset property in JavaScript

Samual Sam
Samual Sam
Updated on 15-Mar-2026 114 Views

The byteOffset property of TypedArray returns the offset (in bytes) from the start of the ArrayBuffer where the typed array begins. Syntax typedArray.byteOffset Parameters This is a property, not a method, so it takes no parameters. Return Value Returns a number representing the byte offset from the beginning of the ArrayBuffer. Example 1: TypedArray at Buffer Start JavaScript byteOffset Example var buffer = new ArrayBuffer(16); ...

Read More

How to write a JavaScript function that returns true if a portion of string 1 can be rearranged to string 2?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 415 Views

We need to write a function that checks if the characters from one string can be rearranged to form another string. This is essentially checking if one string contains all the characters needed to build the second string. The function scramble(str1, str2) should return true if characters from str1 can be rearranged to match str2, otherwise false. Problem Examples str1 = 'cashwool', str2 = 'school' → true (cashwool contains: c, a, s, h, w, o, o, l - enough to make 'school') str1 = 'katas', str2 = 'steak' → false (katas missing 'e' ...

Read More
Showing 18731–18740 of 61,297 articles
Advertisements