Monday, November 18, 2024
Google search engine
HomeLanguagesJavascriptJavaScript typedArray.join() Method

JavaScript typedArray.join() Method

The typedArray.join() is an inbuilt function in JavaScript which is used to join all the elements of the given typedArray into a string. 

Syntax:

typedArray.join(separator);

Parameters: It accepts a parameter “separator” which is used to separate each element of the typedArray. It is optional and its default value is comma (‘,’). 

Return value: It returns a string containing all the joined elements. 

Example: JavaScript code to show the working of this function.

javascript




// Creating some typedArrays
const A = new Uint8Array([1, 2, 3, 4, 5]);
const B = new Uint8Array([5, 10, 15, 20]);
const C = new Uint8Array([0, 2, 4, 6, ,8, 10]);
const D = new Uint8Array([1, 3, 5, 7, 9]);
  
// Calling join() function
a = A.join()
b = B.join('/')
c = C.join('+')
d = D.join('&')
  
// Printing new strings with joined elements
console.log(a);
console.log(b);
console.log(c);
console.log(d);


Output:

1,2,3,4,5
5/10/15/20
0+2+4+6+0+8+10
1&3&5&7&9
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments