# Making a Class; web editor vs local

**URL:** <https://discourse.processing.org/t/making-a-class-web-editor-vs-local/11014>\
**Category:** Coding Questions\
**Created:** [May 7, 2019, 9:40pm UTC](https://discourse.processing.org/t/making-a-class-web-editor-vs-local/11014 "2019-05-07T21:40:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rolembeek](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@Rolembeek](https://discourse.processing.org/u/Rolembeek)\
**Post date:** [May 7, 2019, 9:40pm UTC](https://discourse.processing.org/t/making-a-class-web-editor-vs-local/11014/1 "2019-05-07T21:40:23Z")

</div>

As an exercise in making classes in p5.js, I used a piece of code from Dan Shiffman (2D Ray Casting …).  
Something strange happens : when I use the code -\>

```auto
class Boundary{
   constructor(x1, y1, x2, y2) {
   this.a =createVector(x1,y1);
   this.b =createVector(x2,y2);
   }

   show() {
      stroke(255);
      line(this.a.x, this.a.y, this.b.x, this.b.y);
   }
}

```

it generates an error : Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode  
But only when executed locally.  
When used in “web editor” it runs fine !  
To make it run local I have to declare it as “function” and do the declaration accordingly.

I have searched trough the forum but dit not find any working solution … ☹  
I also downloaded latest version of P5.js with no result…

Thanks for any help !  
Rolembeek

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [May 7, 2019, 9:55pm UTC](https://discourse.processing.org/t/making-a-class-web-editor-vs-local/11014/2 "2019-05-07T21:55:33Z")

</div>

> [@Rolembeek](#):
>
> Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

You’re probably using some very old browser. Perhaps as old as 4 years or more! 👴

---

<div class="post-metadata">

**Author:** ![Rolembeek](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@Rolembeek](https://discourse.processing.org/u/Rolembeek)\
**Post date:** [May 8, 2019, 12:15am UTC](https://discourse.processing.org/t/making-a-class-web-editor-vs-local/11014/3 "2019-05-08T00:15:52Z")

</div>

Thnx for your tip.  
I am currently using Chrome but wil test it imediately in “Microsoft Edge”. (more recent I hope!)  
I’ll post the result.

Cheers,  
Rolembeek

---

<div class="post-metadata">

**Author:** ![Rolembeek](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@Rolembeek](https://discourse.processing.org/u/Rolembeek)\
**Post date:** [May 8, 2019, 12:26am UTC](https://discourse.processing.org/t/making-a-class-web-editor-vs-local/11014/4 "2019-05-08T00:26:30Z")

</div>

I only realize that in fact it IS working in my browser and NOT in local. Does then the browser still have effect on local behaviour ? I checked my Chrome version anuway and it responds that it is uptodate …

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [May 8, 2019, 1:10am UTC](https://discourse.processing.org/t/making-a-class-web-editor-vs-local/11014/5 "2019-05-08T01:10:35Z")

</div>

> [@Rolembeek](#):
>
> I only realize that in fact it IS working in my browser and NOT in local.

What do you exactly mean by local?  
RU trying to use the “file:://” scheme on a Chrome-based browser by any chance?

> [@Code 800A0404 issue](https://discourse.processing.org/t/code-800a0404-issue/2036/3):
>
> Easiest & fastest recipe to run “.js” sketches under p5.js: running_man Install any Firefox-based browser in your OS and use it to open your “index.html” file: fox_faceInstall Notepad2 or Notepad++ (or both) in your OS and use it to type in your “sketch.js” file there: scroll[https://XhmikosR.GitHub.io/notepad2-mod/](https://XhmikosR.GitHub.io/notepad2-mod/)[https://Notepad-Plus-Plus.org](https://Notepad-Plus-Plus.org) You can setup those text editors to use UTF-8 and LF line endings for better compatibility. bulbHere’s my minimum “index.html” te…

> [@Cannot Create Classes](https://discourse.processing.org/t/cannot-create-classes/8756/17):
>
> AFAIK, Firefox-based browsers treat the file:// URL scheme the same way as the http:// URL scheme. fox_face Thus far I haven’t found any issues at all when running Processing sketches on Firefox under its file:// URL scheme. partying_face Firefox-based browsers use the Gecko Spidermonkey JS engine. spider But if we prefer/need to test JS on the Chrome’s Blink V8 engine instead, we can use the Vivaldi browser: musical_score Similarly to Firefox, Vivaldi doesn’t restrict the file:// …

---

<div class="post-metadata">

**Author:** ![Rolembeek](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@Rolembeek](https://discourse.processing.org/u/Rolembeek)\
**Post date:** [May 9, 2019, 9:26pm UTC](https://discourse.processing.org/t/making-a-class-web-editor-vs-local/11014/6 "2019-05-09T21:26:17Z")

</div>

Apparently I didn’t make myself very clear in my question …  
I start all over again 😉

So, I try to write some code with a"Class". (Iused several times in “Processing P3”).  
I took an example from Dan Shiffman (2D Ray Casting …).

When I run this code in the “Web editor”, it runs fine.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/9cae348292b98c32b3a78252cbefa9acf64df01d.png)

Now, when running “localy” by executing “P5.exe” from my HDD (see below)  
 ![P5js_01](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/48ed2c15b97e041d0129b054fb2544f645fdf595.jpeg)

 ![P5js_03](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f6e9011fb4622b392a675ab2dd42d2aa81ec89eb.jpeg)

Now I get an error … ☹

 ![P5js_05](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/6096a48a6fe50ee9b96161db55e58d843e16e2fe.jpeg)

I hope this makes my problem more clear …

Roland

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [May 9, 2019, 10:38pm UTC](https://discourse.processing.org/t/making-a-class-web-editor-vs-local/11014/7 "2019-05-09T22:38:46Z")

</div>

> [@Rolembeek](#):
>
> Now, when running “locally” by executing “p5.exe” from my HDD.

> <https://github.com/processing/p5.js/issues/2044#issuecomment-313378940>
>
> Hello :)
> 
> Was reading through the Get Started doc here https://p5js.org/get-st…arted/ while researching a workshop and noticed this. 
> 
> It seems like referencing an editor that is not easily accessible on the first lines of the getting started document might be more confusing than helpful for the people that document is intended for. As a new user with no programming experience I would be unsure whether I should have this editor before starting the guide. 
> 
> If this is just being left in until the web editor is released that makes total sense, just bringing it up if it happens to be an oversight. 
> 
> 
> Thanks for all the hard work.
> 
> Dex
> 
> 
> \<img width="743" alt="screen shot 2017-07-05 at 5 17 09 pm" src="https://user-images.githubusercontent.com/7800175/27890171-da963a64-61a5-11e7-9b4a-53b2241c6728.png"\>
