JS Object Model (Angular PDX)

JS Object Model (Angular PDX)

If you've ever used JavaScript, you've probably created an object at some point. JavaScript's object model is used by many, but perhaps understood by few. In this talk, we'll explore the inner workings & hidden properties of JS objects, as well as how to interact with them, and why they even matter.

Vaidehi Joshi

April 18, 2019

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

43 slides
  1. {}

  2. let cat = { sayHi: function() { return “Hi!”; }

    }; cat.sayHi = function() { return “No, I will not say hi. I am a cat.”; };
  3. let cat = { sound: “meow”, }; get loudSound() {

    return this.sound.toUppercase() + Math.random(); }
  4. cat.loudSound() > "MEOW0.2812205663401923" get loudSound() { return this.sound.toUppercase() + Math.random();

    } cat.loudSound() > "MEOW0.41972556946839834" cat.loudSound() > “MEOW0.5109470702014649"
  5. let cat = { sound: “meow” }; Object.seal(cat); { configurable:

    false, enumerable: true, value: “meow”, writable: true }
  6. no removing or adding of properties and no writing to

    properties, either! Object.freeze()
  7. let cat = { sound: “meow” }; Object.freeze(cat); { configurable:

    false, enumerable: true, value: “meow”, writable: false }
  8. Object.freeze(cat); A getter’s value isn’t going to be frozen Properties

    that have other objects as their value need to be frozen
  9. Object. getOwnPropertyDescriptors([]) { length: { value: 0, writable: true, enumerable:

    false, configurable: false }, __proto__: Object } we don’t want these to show up in a loop!
  10. objects are complex! but also super cool don’t be afraid

    to peek under the hood at how they work!

More Decks by Vaidehi Joshi

Other Decks in Technology