Found 6710 Articles for Javascript

Atomics.store() function in JavaScript

Samual Sam
Updated on 25-Jun-2020 09:53:45

158 Views

The Atomic object of JavaScript is an object and which provides atomic operations such as add, sub, and, or, xor, load, store etc. as static methods, these methods are used with SharedArrayBuffer objects.The store() function of the atomic object accepts a number(value) and a position in the array and, stores the given value in the specified position and returns the same.SyntaxIts syntax is as followsAtomics.store()Example Live Demo    JavaScript Example           var arrayBuffer = new SharedArrayBuffer(16);       var data = new Uint8Array(arrayBuffer);       data[0] = 20;       Atomics.store(data, ... Read More

Atomics.load() function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 09:54:19

183 Views

The Atomic object of JavaScript is an object and which provides atomic operations such as add, sub, and, or, xor, load, store etc. as static methods, these methods are used with SharedArrayBuffer objects.The load() function of the Atomic object returns the value at a given position of an array.SyntaxIts syntax is as followsAtomics.load()Example Live Demo    JavaScript Example           var arrayBuffer = new SharedArrayBuffer(16);       var data = new Uint8Array(arrayBuffer);       data[0] = 20;       Atomics.add(data, 0, 30);       document.write(Atomics.load(data, 0));     Output50Example Live Demo ... Read More

Atomics.isLockFree() function in JavaScript

Samual Sam
Updated on 25-Jun-2020 09:54:40

135 Views

The Atomic object of JavaScript is an object and which provides atomic operations such as add, sub, and, or, xor, load, store etc. as static methods, these methods are used with SharedArrayBuffer objects.This method is used to determine whether to use locks or atomic operations.SyntaxIts syntax is as followsAtomics.isLockFree(size)Example Live Demo    JavaScript Example           document.write(Atomics.isLockFree(7));       document.write("");       document.write(" "+Atomics.isLockFree(8));     Outputfalse false

Atomics.or() function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 09:55:16

145 Views

The Atomic object of JavaScript is an object and which provides atomic operations such as add, sub, and, or, xor, load, store etc. as static methods, these methods are used with SharedArrayBuffer objects.The or() function of the atomic object accepts a value representing the position of an array, performs bitwise OR operation on the value in the given position and returns the old value in it.SyntaxIts syntax is as followsAtomics.or(data, 0, 30)Example Live Demo    JavaScript Example           var arrayBuffer = new SharedArrayBuffer(16);       var data = new Uint8Array(arrayBuffer);       ... Read More

Atomics.and() function in JavaScript

Samual Sam
Updated on 25-Jun-2020 09:55:53

189 Views

The Atomic object of JavaScript is an object and which provides atomic operations such as add, sub, and, or, xor, load, store etc. as static methods, these methods are used with SharedArrayBuffer objects.The and() function of the Atomic object accepts a value representing the position of an array, performs bitwise AND operation on the value in the given position and returns the old value in it.SyntaxIts syntax is as followsAtomics.and()Example Live Demo    JavaScript Example           var arrayBuffer = new SharedArrayBuffer(16);       var data = new Uint8Array(arrayBuffer);       data[0] = ... Read More

Atomics.add() function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 09:56:17

181 Views

The Atomic object of JavaScript is an object and which provides atomic operations such as add, sub, and, or, xor, load, store etc. as static methods, these methods are used with SharedArrayBuffer objects.The add() function of this object accepts a number and the position, adds the given number to the number in the given position and returns the value of the number in the old position.SyntaxIts syntax is as followsAtomics.add()Example Live Demo    JavaScript Example           var arrayBuffer = new SharedArrayBuffer(16);       var data = new Uint8Array(arrayBuffer);       data[0] = ... Read More

ArrayBuffer.slice() function in JavaScript

Samual Sam
Updated on 25-Jun-2020 09:56:41

521 Views

ArrayBuffer object in JavaScript represents a fixed-length binary data buffer.The slice() method of the this object returns a portion or, chunk from the array buffer (as a separate object). It accepts two integer arguments representing the start (inclusive) and end (exclusive) of the portion of the array to be returned.SyntaxIts syntax is as followsarrayBuffer.slice(start, end);ExampleTry the following example. Live Demo    JavaScript Example           var arrayBuffer = new ArrayBuffer(16);       var int32View = new Int32Array(arrayBuffer);       int32View[1] = 102;       var sliced = new Int32Array(arrayBuffer.slice(4,12));       document.write(" "+sliced);     Output102,0

ArrayBuffer.isView() function in JavaScript

karthikeya Boyini
Updated on 25-Jun-2020 09:57:17

240 Views

ArrayBuffer object in JavaScript represents a fixed-length binary data buffer. The isView() function of this object accepts an argument and verifies whether it is view of ArrayBuffer (DataView, typed array). If so, it returns true else, it returns false.SyntaxIts syntax is as followsarrayBuffer.isView(arg)ExampleTry the following example. Live Demo    JavaScript Example           var arrayBuffer = new ArrayBuffer(5);       arrayBuffer = ["apple", "orange", "mango"];       var bool = ArrayBuffer.isView(new Int32Array())       document.write(bool);     OutputtrueExampleIn the same way if we try executing this function by passing an object ... Read More

ArrayBuffer.byteLength Property in JavaScript

Samual Sam
Updated on 25-Jun-2020 09:43:36

670 Views

ArrayBuffer object in JavaScript represents a fixed-length binary data buffer.The byteLength property of the ArrayBuffer returns an unsigned, 32-bit integer that specifies the size/length of the ArrayBuffer.SyntaxIts syntax is as followsarray.byteLengthExampleTry the following example. Live Demo JavaScript Example           var arrayBuffer = new ArrayBuffer(8);       var result = arrayBuffer.byteLength;       document.write("length of the array buffer is: " + result);     Outputlength of the array buffer is: 8ExampleYou can also create an array buffer object by passing a string value and get its length as in the following example. ... Read More

The Fibonacci sequence in Javascript

karthikeya Boyini
Updated on 22-Jun-2020 15:00:49

514 Views

Fibonacci numbers are the numbers such that every number in the series after the first two is the sum of the two preceding ones. The series starts with 1, 1. Example −1, 1, 2, 3, 5, 8, 13, 21, 34, ….We can write a program to generate nth as follows −functionfibNaive(n) {    if (n

Advertisements