How to Trim data from Ember.get()


#1

I have an Object that has to be trimmed for white-spaces before updating/assigning with ember.set.

I know it can be done with using this.set(/**/).trim() . But just set() is not supporting trim() . And I have been told this.set() is not a best way than compared to just set()

set(Object, Key, get(key, value)) is how my syntax is.

and get(key,value) returns a value that has white spaces in it.


#2

What you suggested here is correct:

trim before assigning with set. The trimming has nothing directly to do with the set. This:

this.set(/**/).trim()

Is doing the trim after the set, which is causing your confusion. This would be trim before set:

this.set(someKey, value.trim())

Lastly, this:

is not really true. Both do the same thing. The only reason to favor set over something.set is when you aren’t sure if something is an Ember.Object. But you’re working with your own this, which you do know is an Ember.Object, so this.set is fine.