mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-25 13:06:22 +00:00
899 B
899 B
id | title |
---|---|
3d5c7ec9-30af-4931-b6ab-2caa687f5951 | JavaScript Object Properties |
Description
Values of the type object are arbitrary collections of properties
Syntax
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:
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
let Object = {
thisExists: true,
};
console.log(Object.undefinedProperty); // undefined