Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4838

[CODE GOLF] Avoiding use of 'this'

$
0
0

@eccegordo wrote:

Watching a presentation by Douglas Crockford he suggested as an exercise to avoid using this inside Javascript programs.

This got me thinking. How to not use this in day to day ember code. I find myself using it all the time, perhaps almost ritualistically.

Would love to see folk's before and after refactor examples following a no this principle.

Start with an example

Person = Ember.Object.extend({
  // these will be supplied by `create`
  firstName: null,
  lastName: null,

  fullName: Ember.computed('firstName', 'lastName', function() {
    return `${this.get('firstName')} ${this.get('lastName')}`;
  })
});

I am not even sure how to remove this.get pattern inside that computed property. Thoughts?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4838

Trending Articles