Skip to content

Instantly share code, notes, and snippets.

@simonjcarr
Last active October 30, 2020 18:12
Show Gist options
  • Save simonjcarr/a829968227c401ebc7b29bf4facc1f6b to your computer and use it in GitHub Desktop.
Save simonjcarr/a829968227c401ebc7b29bf4facc1f6b to your computer and use it in GitHub Desktop.
javascript_objects
let objA = { a: 1, b: 2, c: 3 }
let objB = { a: "X", d: "Y" }
let objC = Object.assign(objA, objB)
console.log("objA:- ", objA)
console.log('objB:- ', objB);
console.log('objC:- ', objC);
const messageObj = {
printMessage: function () {
console.log(`The message: is ${this.message}`)
}
}
newObj = Object.create(messageObj)
newObj.message = "Hello World!"
newObj.printMessage()
let obj = {
a: 1,
b: 2,
c: 3,
messages: {
message1: "1233",
message2: {
detail: "Hello"
}
}
}
console.log(Object.entries(obj))
let obj = {
a: 1,
b: 2,
c: 3,
address: {
line1: '1 street',
postcode: 'XXX XXX',
},
};
console.log(Object.entries());
let obj = {
a: 1,
b: 2,
c: 3
}
Object.freeze(obj)
obj.a = 4
obj.d = 5
delete obj.c
console.log(obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment