# Difference between set and this.set

**URL:** <https://discuss.emberjs.com/t/difference-between-set-and-this-set/17868>\
**Category:** Uncategorized\
**Created:** [May 14, 2020, 5:02am UTC](https://discuss.emberjs.com/t/difference-between-set-and-this-set/17868 "2020-05-14T05:02:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![VYSHNAV\_RAJ\_S](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/vyshnav_raj_s/32/17041_2.png) [@VYSHNAV\_RAJ\_S](https://discuss.emberjs.com/u/VYSHNAV_RAJ_S)\
**Post date:** [May 14, 2020, 5:02am UTC](https://discuss.emberjs.com/t/difference-between-set-and-this-set/17868/1 "2020-05-14T05:02:43Z")

</div>

I have seen people writing code using both set import from ‘@ember/object’ and this.set(key, value). I don’t understand the difference between those two. Can somebody please help me understand the difference?

---

<div class="post-metadata">

**Author:** ![chriskrycho](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/chriskrycho/32/17763_2.png) [@chriskrycho](https://discuss.emberjs.com/u/chriskrycho)\
**Post date:** [May 14, 2020, 11:53am UTC](https://discuss.emberjs.com/t/difference-between-set-and-this-set/17868/2 "2020-05-14T11:53:51Z")

</div>

Your best starting point for questions like this is [the API docs](https://api.emberjs.com/ember/release)! You can search for `set` and it will take you to theses two definitions:

- [set](https://api.emberjs.com/ember/release/modules/@ember%2Fobject)
- [EmberObject.set](https://api.emberjs.com/ember/release/classes/EmberObject/methods/set?anchor=set)

The net is that you can use the imported _function_ `set` with any object in JS, whether it’s related to Ember in any way or not. `this.set` is a _method_ that only exists on `EmberObject` and its subclasses, so you can _only_ use it when you’re working in one of those subclasses (like `Route`, `Controller`, `Service`, etc.).

Note:

- You therefore _cannot_ use `this.set` in a Glimmer component: it is _not_ a subclass of `EmberObject`.
- But you also wouldn’t normally need to, because in Ember Octane, you generally would be using auto-tracking with the `@tracked` decorator, and therefore could just use normal JS assignment without worrying about `set` at all!
