Understanding prototype extensions

In this video we'll look at how Ember's prototype extensions affect native Javascript arrays.

Summary

Ember extends the native Array prototype with a number of mixins to make working with arrays easier.

This means that Ember specific methods like pushObject will work on any array, regardless of how it was created. This is helpful because it avoids developers needing to consciously think about the difference between native arrays and Ember arrays.

However, extension can also be confusing and unexpected to developers that are unfamiliar with Ember's mixins. Prototype extensions can be disabled in the Ember environment config file.

// config/environment.js

ENV = {
  EmberENV: {
    EXTEND_PROTOTYPES: false
  }
}

Questions?

Send us a tweet:

Or ask us in Inside EmberMap, our private Slack workspace for subscribers.