Animations

API

Arrays

Async

Basics

Challenges

Classes

Console

Dates

Debugging

DOM Elements

DOM Methods

DOM Navigation

DOM Properties

Event Listeners

Flow Control

Forms

Functions

Global Functions

JSON

Keywords

Libraries (3rd party)

Math

Modules

Objects

Snippets

String

Types

Widgets

Window Object

JavaScript - Object Literals

When you define an object "hard-coded style" (object literal), you can do a few things.


let mystery = "SecretToLife";

let Spaceship =
{
Designation : "NCC-1701",
Name : "Enterprise",
CalculateSpeed() {return 100; },
CalculateCrew: (crew) => { return crew * 1; },

// note the name of this property is set elsewhere!
// this is known as a dynamic property.
[mystery] : 42
};