O'Reilly logo

Mastering Ember.js by Mitchel Kelonye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing object properties

We have just seen how Ember.js objects are created. Did you notice how Ember.js object properties are accessed? Ember.js provides the get and set property accessor methods. Why not access these values directly? Well, these methods are used to recalculate values as well as notify any changes made when necessary. For example:

var point = Point.create();
point.set('x', 3);
console.log(point.get('x')); // 3

Properties can also be read and set collectively using the getProperties and setProperties methods. This prevents Ember.js from unnecessarily making too many notifications about these changes, for example:

var point = Point.create(); point.setProperties({ x: 1, y: 2, z: 3 }); console.log(point.getProperties('x', 'y', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required