๐Ÿ–จ๏ธ COSMOS PRINTER
๐Ÿšš Shipping from 12 USD
๐Ÿ’ฐ DEALS OF THE DAY

Uint8Array

About

The Uint8Array is a built-in data structure in MagiScript which allows you to store an array of 8-bit unsigned integers (values between 0 and 255). This data structure is particularly useful when you need to store a large number of small integers in a memory-efficient way.

It is a specialized array, with fix length and restricted values.

Creating a Uint8Array

You can create aย Uint8Arrayย by calling theย newUint8Arrayย function with a single argument: the size of the array. For example, the following code creates aย Uint8Arrayย with 10 elements:

				
					let myArray = newUint8Array(10);
				
			

Accessing Array Items

You can access the elements of aย Uint8Arrayย using the bracket notation ([]). The index of the first element isย 0, and the index of the last element isย length - 1.

For example, the following code sets the first element of theย myArrayย toย 42:

				
					myArray[0] = 42;
				
			

And the following code retrieves the value of the third element:

				
					let thirdElement = myArray[2];
				
			

Querying the Length

You can query the length of aย Uint8Arrayย using theย lengthย property. For example, the following code prints the length of theย myArray:

				
					console.log(myArray.length);
				
			

Example

The following code creates a Uint8Array with 5 elements, sets their values to 0, 1, 2, 3, and 4, respectively, and then prints them:

				
					let myArray = newUint8Array(5);

for (let i = 0; i < myArray.length; i++) {
  myArray[i] = i;
}

for (let i = 0; i < myArray.length; i++) {
  console.log(myArray[i]);
}
				
			

This will output the numbers from 0 to 5.

Conclusion

The Uint8Array is a memory-efficient data structure that allows you to store an array of 8-bit unsigned integers in MagiScript. You can create a Uint8Array by calling the newUint8Array function with a single argument: the size of the array. You can access the elements of a Uint8Array using the bracket notation, and query its length using the length property.

General

๐Ÿ“ƒ First Steps

MagiScript Editor

๐Ÿ“ƒ Basics

๐Ÿ“ƒ Keyboard Shortcuts

๐Ÿ“ƒ Running Your First Program

๐Ÿ“ƒ App Store

๐Ÿ“ƒ Atom Settings (Editor)

๐Ÿ“ƒ Debugging Techniques

Examples

๐Ÿ“ƒ Atom Time

๐ŸŽž๏ธ Time Practice

๐Ÿ“ƒ Atom Pi (Pi Revelations)

๐Ÿ“ƒ Atom Drum

๐ŸŽž๏ธ Atom Stack

๐Ÿ“ƒ Atom Square

๐Ÿ“ƒ Atom Level

๐Ÿ“ƒ Atom THMPR

๐Ÿ“ƒ Poker Hands

๐Ÿ“ƒ Keyboard Numeric

๐Ÿ“ƒ Keyboard NOKIA

๐Ÿ“ƒ Keyboard Cursor

๐Ÿ“ƒ Keyboard Media

๐Ÿ“ƒ Keyboard Custom

Input/Output

๐Ÿ“ƒ Buttons

๐Ÿ“ƒ Vibration Motor

๐Ÿ“ƒ RGB LED

๐Ÿ“ƒ Devices

๐Ÿ“ƒ PeekSmith

๐Ÿ“ƒ Quantum

๐Ÿ“ƒ Teleport

๐Ÿ“ƒ Spotted Dice

๐Ÿ“ƒ SB Watch

๐Ÿ“ƒ IARVEL Watch

๐Ÿ“ƒ Fossil Watch

๐Ÿ“ƒ Cosmos Printer

๐Ÿ“ƒ PeriPage Printer

๐Ÿ“ƒ ATC Remote

๐Ÿ“ƒ Labko Scrabble

๐Ÿ“ƒ Bluetooth Keyboard

๐Ÿ“ƒ Bluetooth Mouse

๐Ÿ“ƒ Timers

๐Ÿ“ƒ Database

๐Ÿ“ƒ Events

๐Ÿ“ƒ System (exit, sleep, rand)

๐Ÿ“ƒ Objects (card, time)

Language

๐Ÿ“ƒ Summary

๐Ÿ“ƒ Comments

๐Ÿ“ƒ Variable Declarations

๐Ÿ“ƒ Operators

๐Ÿ“ƒ Control Flow

๐Ÿ“ƒ Functions

๐Ÿ“ƒ Numbers

๐Ÿ“ƒ Strings

๐Ÿ“ƒ Arrays

๐Ÿ“ƒ Objects

๐Ÿ“ƒ Uint8Array