Last active
April 6, 2022 19:14
-
-
Save razouck/e36b1842362995999de46af47bf49d6c to your computer and use it in GitHub Desktop.
How to Create an Object in JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var object; | |
object = {}; | |
object = new Object(); | |
object = new Object(null); | |
object = new Object(undefined); | |
object = Object.create(Object.prototype); | |
object = Reflect.constructor(Object.prototype); | |
var prop = 'value'; | |
object = { prop }; | |
object = { prop: 'value' }; | |
object = new Object({ prop: 'value' }); | |
object = Reflect.constructor({prop: 'value'}); | |
object = Object.create(Object.prototype, { | |
prop: { | |
value: 'value', | |
writable: true, | |
enumerable: true, | |
configurable: true | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment