Working with classes and instances

Creating and extending classes is a major feature of the Ember object model. In this recipe, we'll take a look at how creating and extending objects works.

How to do it...

  1. Let's begin by creating a very simple Ember class using extend():
    const Light = Ember.Object.extend({
      isOn: false
    });

    This defines a new Light class with a property called isOn. Light inherits properties and behavior from the Ember object, such as initializers, mixins, and computed properties.

    Tip

    Ember Twiddle tip

    At any point of time, you might need to test out small snippets of the Ember code. An easy way to do this is to use a website called Ember Twiddle. From this website, you can create an Ember application and run it in the browser as if ...

Get Ember.js Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.