Javascript with Atomic,BigUint64Array, Boolean, DataView, decodeURI(), encodeURI()
Tags: javascript, webdev, beginners, programming
Published: 2023-09-13 19:00:00

## Introduction

As a versatile and widely used programming language, JavaScript offers many features and functions. In this article, we will explore a set of basic JavaScript elements that every student should know. 

These include Atomic, BigInt, BigInt64Array, BigUint64Array, Boolean, DataView, Date, decodeURI(), decodeURIComponent(), encodeURI(), encodeURIComponent(), error, escape() (default), value(), EvalError, FinalizationRegistry, and Floating64Array. We will explore each concept with simple examples to help you understand the basic application.

## 1. Atomics

Atomics objects provide atomic operations as static methods for shared memory and web workers. It is commonly used in multi-threaded JavaScript applications to ensure thread safety. Here is a basic example using Atomics:

```javascript
const sharedArray = new Int32Array(new SharedArrayBuffer(4));

// Atomically update the shared array
Atomics.store(sharedArray, 0, 42);
console.log (Atomics.load (sharedArray, 0)); // 42
```

## 2. BigInt

"BigInt" is an internal object that provides arbitrary precision numbers. Lets you work with numbers outside the scope of standard JavaScript numbers.

```javascript
const bigIntNum = 1234567890123456789012345678901234567890n;
console.log(bigIntNum); // 1234567890123456789012345678901234567890n
```

## 3. BigInt64Array and BigUint64Array

These typed Array objects allow working with signed and 64-bit integers, respectively.

```javascript
const int64Array = new BigInt64Array([BigInt(42), BigInt(84)]);
console.log(int64Array[0]); // 42n

const uint64Array = new BigUint64Array([BigInt(42), BigInt(84)]);
console.log(uint64Array [1]); // 84n
```

## 4. Boolean

A Boolean object represents a value. It is often used to change the shape or create an object.

```javascript
const boolValue = new Boolean(false);
console.log(boolValue.valueOf()); // false
```

## 5. DataView

DataView is used to read and write raw binary data to the buffer.

```javascript
const buffer = new ArrayBuffer(4);
const view = new DataView(buffer);
view.setInt32(0, 42);
console.log(view.getInt32(0)); // 42
```

## 6. Date

Date objects represent dates and times. It is widely used to work with dates and run date calculations.

```javascript
const today = new Date();
console.log(today.toDateString()); // eg "September 13, 2023"
```

## 7. decodeURI() and decodeURIComponent()

This function encodes URI or URI component encoded using "encodeURI()" or "encodeURIComponent()".

```javascript
const encodedURI = "https%3A%2F%2Fwww.example.com%2F";
const decodeURI = decodeURI( decodeURI );
console.log (decoded); // "https://www.example.com/"
```

## 8. encodeURI() and encodeURIComponent()

"encodeURI()" and "encodeURIComponent()" encode URI or URI component for secure transmission.

```javascript
const originalURI = "https://www.example.com/";
const encodedURI = encodeURI(originalURI);
console.log(encodeURI); // "https://www.example.com/"
```

## 9. Error

An "Error" object represents an error in JavaScript. The base object for all error types.

```javascript
try {
  throw new Error("This is an error.");
} catch (error) {
  console.error(error.message); // "This is an error."
}
```

## 10. escape() (deprecated)

`escape()` is an old function used to escape characters in a string. Not recommended for modern JavaScript.

```javascript
const originalString = "Hello, world!";
const escapedString = escaped(originalString);
console.log(escapedString); // "Hello %2C%20world%21"
```

## The results

These JavaScript properties and objects are fundamental to mastering the language. Whether you're working with data, handling errors, or manipulating numbers, understanding these concepts will provide a solid foundation for your JavaScript journey. As you progress in your coding career, you'll find these tools invaluable for building more complex and advanced applications.