Essential JavaScript
Introduction
JavaScript Basics
Numbers
Strings
Logic
Variables
Loops
Objects
Arrays
Arrays Intro
Making Arrays
Array Builder Kata
Array Elements
Human Names Kata
Array Length
Longest Array Kata
Looping Over Arrays
Highest Number Kata
Word Hunter Kata
Array Average Kata
Min-Max Kata
Adding Elements
Number Range Kata
Removing Elements
Arrays of Objects
Biggest Animal Kata
Arrays of Arrays
Taboo Words Kata
Going Further
Essential JavaScript
Introduction
JavaScript Basics
Numbers
Strings
Logic
Variables
Loops
Objects
Arrays
Arrays Intro
Making Arrays
Array Builder Kata
Array Elements
Human Names Kata
Array Length
Longest Array Kata
Looping Over Arrays
Highest Number Kata
Word Hunter Kata
Array Average Kata
Min-Max Kata
Adding Elements
Number Range Kata
Removing Elements
Arrays of Objects
Biggest Animal Kata
Arrays of Arrays
Taboo Words Kata
Going Further
Making Objects
It's easy to create your own objects.
To create an empty object, simply assign a pair of curly braces to a variable:
const person = {};
This will give us an object with no properties.
To give an object properties, put them between the curly braces. Property names look like variable names - they should be in camel case:
const person = { firstName: 'John', lastName: 'Doe', age: 22, likesSpicyFood: true, };
Now our object has four properties: firstName
, lastName
, age
, and likesSpicyFood
.
Both firstName
and lastName
are strings, age
is a number, and likesSpicyFood
is Boolean.
Object properties can be any type.
Learning Goals
I can defined an object and assign it to a variable
I can give an object properties that are any type
Code Editor
Click "Run Code" to execute your JavaScript in a secure sandbox and see the output below.
Console Output
// Console output will appear here...
0 output lines