Newbie issue with intro docs on extend()


#1

So http://guides.emberjs.com/v2.0.0/object-model/classes-and-instances/ offers up

Person = Ember.Object.extend({
  say(thing) {
  alert(thing);
   }
});

I know a fair amount of .js but wasn’t sure what the syntax meant - like if I wanted a

 whisper(thing) { console.log(whisper); }

what would the syntax be?? I googled and got to http://emberjs.com/api/classes/Ember.Object.html#method_extend which had a version that seemed to be a lot more recognizable:

 App.Person = Ember.Object.extend({
 say: function(thing) {
   alert(thing);
  }
  });

Feels like I can apply what I know about js maps, no problem? So unfortunately none of the examples on the first page cover "so you want to extend an object with multiple functions… what does that look like, and what would have been the best way for me to have learned it?


#2

What you’re looking is a new way of declaring methods on an object in shorthand manner. The good thing is you can mix and match, you’re not forced into writing ES2015. So if you prefer the long way, continue to use it… it doesn’t matter to Ember or Ember CLI.


#3

Aha, thanks. I’d only seen the new syntax in a conference. So Ember is taking care of any shimming or whatever for browsers to support both syntaxes? Or do you need to keep to the old syntax if you’re at all backwards compatible?


#4

Yes, Ember CLI uses the babel transpiler during build. Read - or watch the video - under ES6 (and Beyond) in http://brewhouse.io/blog/2015/05/13/emberjs-an-antidote-to-your-hype-fatigue.html which overall gave me a good 10.000 ft “why Ember overview” (I’m fairly new to Ember too)

Regarding browser backwards compatibility IE9+ is supported going forward from the recent Ember 2.0. If you currently need IE8 you must step back to ember 1.13.X.