- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Atomics.load() function in JavaScript
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.
Syntax
Its syntax is as follows
Atomics.load()
Example
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var arrayBuffer = new SharedArrayBuffer(16); var data = new Uint8Array(arrayBuffer); data[0] = 20; Atomics.add(data, 0, 30); document.write(Atomics.load(data, 0)); </script> </body> </html>
Output
50
Example
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var arrayBuffer = new SharedArrayBuffer(16); var data = new Uint8Array(arrayBuffer); data[0] = 3; document.write(Atomics.add(data, 0, 3)); document.write(", "+Atomics.load(data, 0)); </script> </body> </html>
Output
3, 6
Advertisements