wiki/content/20201113091110-javascript_object_properties.md

50 lines
914 B
Markdown
Raw Normal View History

2024-05-06 20:40:05 +00:00
---
2024-10-30 17:04:36 +00:00
date: 20201113
2024-05-06 20:40:05 +00:00
id: 3d5c7ec9-30af-4931-b6ab-2caa687f5951
title: JavaScript Object Properties
---
# Description
Values of the type [object](20200826201605-objects) are arbitrary
collections of properties
# Syntax
``` javascript
let tralala = {
distro: "Arch",
useWindows: false,
aListOfRandomThings: ["spoon", "fork", "modem", "keychain"],
};
console.log(tralala.distro);
console.log(tralala.useWindows);
console.log(tralala.aListOfRandomThings);
```
# Invalid binding names
Properties with invalid binding names or numbers must be quoted:
``` javascript
let weirdObject = {
tralala: "Chipmunk",
"this is a long binding name with spaces": "Fill in some nonsensse here"
}
console.log(weirdObject)
```
# Non existant property
Reading a non existant property returns `undefined`
``` javascript
let Object = {
thisExists: true,
};
console.log(Object.undefinedProperty); // undefined
```