JavaScript by Patrik

JavaScript Collection

JavaScript collections refer to data structures in the JavaScript programming language that are used to store and manipulate collections of values or objects. These collections provide various ways to organize and access data efficiently. There are several built-in collection types in JavaScript, and developers can also create custom collections as needed.

In JavaScript, collections like arrays, objects, sets, and maps are built-in language features. They are part of the core JavaScript language and do not require any external extensions or libraries to use. JavaScript provides these data structures as fundamental constructs for working with and organizing data within your programs.

...see more

Arrays are ordered collections of values, and they are perhaps the most commonly used data structure in JavaScript. Elements in an array can be accessed by their index, and arrays can hold values of different data types.

let myArray = [1, 2, 3, 4, 5];
console.log(myArray[0]); // Accessing the first element


...see more

Objects in JavaScript are collections of key-value pairs. They are versatile and can be used to represent a wide range of data structures. Objects are often used for creating dictionaries, maps, and records.

let person = {
    name: "Maria",
    age: 28,
    city: "New York"
console.log(; // Accessing a property

Keys are always strings (or Symbols, introduced in ES6). When you use non-string values as keys in an object, JavaScript implicitly converts them to strings.

Objects are generally used for a simple dictionary-like structure with string keys.


Leave a Comment

All fields are required. Your email address will not be published.