Found 8862 Articles for Front End Technology

TypedArray.set() function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 13:36:31

16 Views

The set() function of TypedArray object accepts an array a number representing the index and copies the contents of the specified array in to the current array starting at the given index.SyntaxIts Syntax is as followstypedArray.set()Example Live Demo    JavaScript Array every Method           var typedArray1 = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]);       document.write("Contents of the typed array: "+typedArray1);       document.write("");       var typedArray2 = new Int32Array([110, 215, 316, 916, 616, 117, 311 ]);       typedArray1.set(typedArray2, 3);       document.write("Result: "+typedArray1);     OutputContents of the typed array: 11,5,13,4,15,3,17,2,19,8 Result: 11,5,13,110,215,316,916,616,117,311

TypedArray.reverse() function in JavaScript

Samual Sam
Updated on 25-Jun-2020 13:17:39

46 Views

The reverse() function of the TypedArray object reverses the contents of a typed array.SyntaxIts Syntax is as followstypedArray.reverse()Example Live Demo    JavaScript Array every Method           var typedArray = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]);       document.write("Contents of the typed array: "+typedArray);       document.write("");       var result = typedArray.reverse(Math.sqrt);       document.write("Contents of the reversed array: "+result);     OutputContents of the typed array: 11,5,13,4,15,3,17,2,19,8 Contents of the reversed array: 8,19,2,17,3,15,4,13,5,11

TypedArray.map() function in JavaScript

Samual Sam
Updated on 25-Jun-2020 13:20:09

45 Views

The map() function of the TypedArray object accepts the name of a function and calls it on every element of the typed array and returns the results.SyntaxIts Syntax is as followstypedArray.map()Example Live Demo    JavaScript Array every Method           var int32View = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]);       document.write("Contents of the typed array: "+int32View);       document.write("");       function square(ele) {          return ele*ele;       }    var result = int32View.map(square);    document.write("Specified element occurred at the index: "+result); OutputContents of the typed array: 11,5,13,4,15,3,17,2,19,8 Specified element occurred at the index: 121,25,169,16,225,9,289,4,361,64

TypedArray.lastIndexOf() function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 13:21:29

27 Views

The lastIndexOf() function of the TypedArray object accepts a value and verifies whether the typed array contains the specified element. If so, this function returns the index of the array at which the specified element found, if the element occurred multiple timed this function returns the last index among them. If the array doesn’t contain the specified element the indexOf() function returns -1.SyntaxIts Syntax is as followstypedArray.lastIndexOf(50)Example Live Demo    JavaScript Array every Method           var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55, 66, 97, 66 ]);       ... Read More

TypedArray.keys() function in JavaScript

Samual Sam
Updated on 25-Jun-2020 13:22:23

31 Views

The keys() function of typedArray object is similar to entries but, it returns an iterator object containing the indices of the typed array.SyntaxIts Syntax is as followstypedArray.keys()Example Live Demo    JavaScript Array every Method           var int32View = new Int32Array([21, 64, 89, 65, 33, 66, 87, 55]);       document.write("Contents of the typed array: "+int32View);       document.write("");       var it = int32View.keys();       for(i=0; i

TypedArray.join() function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 13:23:10

38 Views

The join() function of the TypedArray object joins the contents of the typed array as single string and returns it. To this method you can pass a separator to separates the elements of the array.SyntaxIts Syntax is as followstypedArray.join(':')Example Live Demo    JavaScript Array every Method           var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55 ]);       document.write("");       var contains = int32View.join('');       document.write("."+contains);       document.write("");       document.write(int32View.join(':'));       document.write("");       document.write(int32View.join('-'));       ... Read More

TypedArray.indexOf() function in JavaScript

Samual Sam
Updated on 25-Jun-2020 13:25:17

39 Views

The indexOf() function of the TypedArray object accepts a value and verifies whether the typed array contains the specified element. If so, this function returns the index of the array at which the specified element found, if the element occurred multiple timed this function returns the first index among them. If the array doesn’t contain the specified element the indexOf() function returns -1.SyntaxIts Syntax is as followstypedArray.indexOf(50)Example Live Demo    JavaScript Array every Method           var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55, 66, 97, 66 ]);       ... Read More

TypedArray.includes() function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 13:27:01

24 Views

The includes() function of the TypedArray object accepts a value and verifies whether this typed array contains the specified element. If the array contains the given element it returns true else, it returns false.SyntaxIts Syntax is as followstypedArray.includes()Example Live Demo    JavaScript Array every Method           var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55 ]);       document.write("Contents of the typed array: "+int32View);       document.write("");       var contains = int32View.includes(66);       if(contains) {          document.write("Array contains the specified element");   ... Read More

TypedArray.forEach() function in JavaScript

Samual Sam
Updated on 25-Jun-2020 13:27:34

30 Views

The forEach() function of TypedArray object accepts a string value representing the name of a function and executes it per every element in the array.SyntaxIts Syntax is as followstypedArray.forEach()Example Live Demo    JavaScript Array every Method           var int32View = new Int32Array([21, 19, 65,21, 14, 66, 87, 55 ]);       document.write("Contents of the typed array: "+int32View);       document.write("");       document.write("Result: ");       function testResult(element, index, array) {          document.writeln(element+100);       }       int32View.forEach(testResult);       //document.write("Result: "+result);     OutputContents of the typed array: 21,19,65,21,14,66,87,55 Result: 121 119 165 121 114 166 187 155

TypedArray.findIndex() function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 13:28:23

22 Views

The find() function of TypedArray accepts a string value representing the name of a function, tests whether the elements in the array passes the test implemented by the provided function, if so, returns the index of the first element which passes the test else, returns -1.SyntaxIts Syntax is as followstypedArray.findIndex(function_name)Example Live Demo    JavaScript Array every Method           var int32View = new Int32Array([21, 19, 65, 21, 14, 66, 87, 55 ]);       document.write("Contents of the typed array: "+int32View);       document.write("");       function testResult(element, index, array) {     ... Read More

Advertisements