# context keyword

**URL:** <https://es.discourse.group/t/context-keyword/1275>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [April 3, 2022, 2:40pm UTC](https://es.discourse.group/t/context-keyword/1275 "2022-04-03T14:40:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aliibrahim123](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aliibrahim123/32/1315_2.png) [@aliibrahim123](https://es.discourse.group/u/aliibrahim123)\
**Post date:** [April 3, 2022, 2:40pm UTC](https://es.discourse.group/t/context-keyword/1275/1 "2022-04-03T14:40:25Z")

</div>

an array like object to view the current context in the current function. like this

```javascript
var example1 = "example";
function example() {
var example2 = "another example";
console.log(context);
}
///context:[
///{example2:"another example"}, 
///globalThis
///] 

```

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [April 3, 2022, 3:29pm UTC](https://es.discourse.group/t/context-keyword/1275/2 "2022-04-03T15:29:45Z")

</div>

Why? What’s your use case for a “scope object”?

Your example omits `example1` as well.

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [April 3, 2022, 5:07pm UTC](https://es.discourse.group/t/context-keyword/1275/3 "2022-04-03T17:07:04Z")

</div>

I think the example output didn't include `example1` because the function didn't reference it, so it isn't actually available in that context.

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [April 3, 2022, 5:17pm UTC](https://es.discourse.group/t/context-keyword/1275/4 "2022-04-03T17:17:40Z")

</div>

Hi @aliibrahim123, welcome!

This might be something you could achieve with a build-step (e.g. [https://babeljs.io](https://babeljs.io)) if you have a particular project that requires this information at runtime.

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [April 3, 2022, 6:02pm UTC](https://es.discourse.group/t/context-keyword/1275/5 "2022-04-03T18:02:27Z")

</div>

Yes, but it could if it used eval. If it’s about “context” then that’d be what’s potentially available, whether it’s referenced or not.

If it’s about what’s referenced, then that’s a bit different and wouldn’t include globalThis.

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [April 3, 2022, 7:42pm UTC](https://es.discourse.group/t/context-keyword/1275/6 "2022-04-03T19:42:38Z")

</div>

Right, I was thinking about how this tends to be implemented in engines where without the presence of an `eval` only referenced bindings are captured.
