JavaScript, Functional Programming, Web Development, State Encapsulation, Javascript State.
with. All we’re doing is writing a function that returns an object literal; not exactly rocket science. This is how we declare our function: const MyObj2 = initVal => { return { myVal: initVal, set: function(x) { this.myVal = x } } } Notice that you didn’t need to learn about class or constructor