# Ember computed properties with no dependencies

**URL:** <https://discuss.emberjs.com/t/ember-computed-properties-with-no-dependencies/17544>\
**Category:** Uncategorized\
**Created:** [February 21, 2020, 6:32pm UTC](https://discuss.emberjs.com/t/ember-computed-properties-with-no-dependencies/17544 "2020-02-21T18:32:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![harimath](https://avatars.discourse-cdn.com/v4/letter/h/76d3ee/32.png) [@harimath](https://discuss.emberjs.com/u/harimath)\
**Post date:** [February 21, 2020, 6:32pm UTC](https://discuss.emberjs.com/t/ember-computed-properties-with-no-dependencies/17544/1 "2020-02-21T18:32:55Z")

</div>

A lot of times, I have seen computed properties used in code with no dependencies specified. I wanted to understand what is the purpose of such CP’s ?

Example;

```
someCP: computed({
// some code
})

```

---

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [February 21, 2020, 6:38pm UTC](https://discuss.emberjs.com/t/ember-computed-properties-with-no-dependencies/17544/2 "2020-02-21T18:38:40Z")

</div>

It’s basically a lazily computed value that stays cached after the first time it’s needed. A computed like:

```nohighlight
someCP: computed(function() {
  return 1 + 1;
})

```

Is equivalent to manually doing:

```auto
get someCP() {
  if (this._alreadyComputed != null) {
    this._alreadyComputed = 1 + 1;
  }
  return this._alreadyComputed;
}

```

In both cases, the actual computation only happens the first time somebody tries to use `someCP`.

---

<div class="post-metadata">

**Author:** ![harimath](https://avatars.discourse-cdn.com/v4/letter/h/76d3ee/32.png) [@harimath](https://discuss.emberjs.com/u/harimath)\
**Post date:** [February 21, 2020, 6:42pm UTC](https://discuss.emberjs.com/t/ember-computed-properties-with-no-dependencies/17544/3 "2020-02-21T18:42:59Z")

</div>

> [@ef4](#):
>
> get someCP() {

Thanks a lot for your reply…So when you say get someCP() {}, do you mean equivalent to a normal method call which checks if existing and does computation only \_alreadyComputed is not null. I got a bit confused as you have a “get” in the front of someCP

---

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [February 21, 2020, 7:05pm UTC](https://discuss.emberjs.com/t/ember-computed-properties-with-no-dependencies/17544/4 "2020-02-21T19:05:16Z")

</div>

The `get` is a standard Javascript feature, not an ember thing.

```nohighlight
class Thing {
  get value() {
    return 42;
  }
}
let t = new Thing();
console.log(t.value); // prints 42;

```
