The Atromic operations are installed on an Atomics Module. Unlike other global objects, Atomics is not a constructor. Atomics cannot be used with a new operator or can be invoked as a function.
Atomic operations are not uninterruptible. When memory is shared, multiple threads can read or write an existed data in the memory. So if any data got changed, there will be a loss of data Atomic operations make sure that predicted values(data) are written and read accurately. Atomic operations wont start until and unless the current operation is finished, so there is no way to change an existed data.
Now, lets discuss one of the Automics methods.
Atomics.Add() is used to add a given value at a given position in an array and return the old value at that position. Since no interruptions are allowed, no other write function can takes place until the modified value is returned.
Atomics.add(typedArray, index, value)
It's an shared array integer that we are going to modify.
The index in the array where we are going to add a new value.
It is nothing but the number we are going to add.
Atomics.add() returns the old value at the given position(typedArray[index]).