samedi 30 janvier 2016

this.get('x') returns ' undefined' instead of 'undefined'

In a form-component I have an observer that tests if a property is valid before to start further validations.
So I checked if the property has not yet been defined (happens at initialization f.e.)

if(typeof this.get('myProperty') !== 'undefined') { 
    //do smth 
}

Then I realized that this.get would not return a type of 'undefined' but a string with the value undefined.
Fair enough.

BUT

console.log(this.get('myProperty'));

gives me ' undefined' instead of 'undefined' - notice the space before 'undefined'!

Is this a bug?
Or do I really have to check for ' undefined' with a space and is there a reason for that?

Ember-cli: 1.13.7
Ember: 2.0.1




Aucun commentaire:

Enregistrer un commentaire