rockandrollwithemberjs / rarwe-issues

Errata and updates for the Rock and Roll with Ember.js book
https://rockandrollwithemberjs.com
43 stars 4 forks source link

The rating public class field doesn't work as intended #458

Closed balinterdi closed 4 years ago

balinterdi commented 4 years ago

The below code will not default the rating property of Song to 0 if no rating is passed in:

export default class Song {
  title = '';
  rating = 0;
  band = null;

  constructor({ title, rating, band }) {
    this.title = title;
    this.rating = rating;
    this.band = band;
  }
}

It probably makes no sense to have class fields at all for Band and Song.