Crockford Objects in JavaScript
The example that Crockford gave in his presentation on how to create objects is the way developers should use for creating objects. It does not require the 'class' keyword or the 'prototype' property for defining an object. It also does not require using the 'new' keyword for instantiating a new object.
function createThing(name) {
function getName() {
return name;
}
return Object.freeze({
name,
getName
});
}
const myThing = createThing('My Thing');
September 16, 2021 at 11:06:32 AM EDT
*
FILLER