O'Reilly logo

Ember.js Web Development with Ember CLI by Suchit Puri

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

Prototype extensions

To make your life simpler, Ember.js framework extends the prototypes of Array, String, Function are native JavaScript objects. These extensions provide you with simpler ways of accessing and manipulating these native objects.

As for arrays, you could do the following:

export default function(){
  console.log([1,2,3].get('lastObject')); //4

  var arr = [1,2,3,4,5,6,7].filter(function(item){
    if(item < 5){
      return true;
    }
  });
  console.log(arr);//[1,2,3,4]
}

The contents of prototype.js are present in chapter-2/example10/app/prototype.js

For strings, you could do the following:

console.log("ember.js".capitalize()); //Ember.js
console.log("my var".camelize());//myVar
console.log("my var".classify());//MyVar

Note

For a complete list of Array ...

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