Keyed Data Structures in JavaScript I
JavaScript·2 min read·Jan 1, 2025
In JavaScript, an object is a dynamic data structure that contains a collection of related data and complex entities in the form of key-value pairs called properties.
These values include all primitive data types, objects, arrays, functions, and regular expressions.
Objects are commonly used to:
- Group together multiple values into a single entity.
- Create models of real-world entities, such as users or products.
- Bundle multiple functionalities together to improve code reusability.
- Create complex data structures that can easily be manipulated by APIs.
Creating new objects
In JavaScript, empty objects are created using curly brackets {}:
variable = {};Note: Any object created using this method is referred to as an object literal.
Declaring object properties
Object properties are unique keys-value pairs separated by a comma character:
{Unlock the Build CLI Apps in JavaScript & Node.js module
Learn how to build, integrate, and safeguard scalable CLI tools, scripts, and apps with JavaScript, Node.js, npm, and Git.
You get immediate access to:
- 45 focused lessons across JavaScript, Node.js, npm, and Git
- 17 real-world projects with commented solutions
- Ongoing updates to this bundle
- Lifetime access to this bundle