# Correct way to use ES6 modules and import classes

**URL:** <https://discourse.processing.org/t/correct-way-to-use-es6-modules-and-import-classes/21386>\
**Category:** Coding Questions\
**Created:** [May 28, 2020, 10:54pm UTC](https://discourse.processing.org/t/correct-way-to-use-es6-modules-and-import-classes/21386 "2020-05-28T22:54:08Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [May 29, 2020, 8:34am UTC](https://discourse.processing.org/t/correct-way-to-use-es6-modules-and-import-classes/21386/5 "2020-05-29T08:34:18Z")

</div>

All right thanks for the example.

I noticed that in JavaScript, we must use the keyword `this` to refer an attribute inside a class that’s why you say (in your example) :

```auto
const { p, c } = this;

```

but it’s not efficient at all isn’t it? It means that at each method call, you are going to create a variable.  
In the same time, saying :

```auto
this.p.ellipse(...);
this.p.random();
this.p.fill();
// ...

```

is quite heavy when writing ☹

---

_[View the full topic](https://discourse.processing.org/t/correct-way-to-use-es6-modules-and-import-classes/21386)._
