Learning JS for Spark

Hey guys,

I have lecture-free time for the next month and thought about diving deeper into creating effects with javascript.

I‘m working with Spark since a year and I know how to implement code. I also had 1 semester of java coding on my old college. I know that it is different to js but I think it gives me some basic understanding of e.g. if/else loops etc.

My question to you:
*** How would you start with js if you would be at my point of coding knowledge? **
*** Wich sources would you use for learning? (I‘m member on LinkedIn learning, Youtube, Books,…)**
*** Would you first learn js in general and after that specified on Spark? Or directly specified on Spark?**

Thanks a lot for your help!

I found out about this forum a few months ago but had some general brake at that time. I have to say I really like it. Especially that it‘s in the format of a real forum not just a FB group. It feels more serious and purposeful.

Keep it going!

3 Likes

Glad you like the forum! The Spark FB group is great for discussions, but it’s really a pain to find answers by searching. Also, yeah… facebook can be a bit distracting when trying to work :slight_smile:

The nice thing about JS is that it’s been around for ages, so there’s lots of content around it. You can even pop open the browser devtools and quickly type some code to try it out. I learned almost a decade ago so my books are a little outdated and things have changed quite a bit since then.

I would recommend learning JS outside of Spark and then bringing your knowledge into Spark when you feel ready. There are a handful of JS features I would look into:

  • Arrays
  • Variables
  • Promises
  • Async/await
  • Functions
  • Classes

Beyond that, I would spend a lot of time digging around in the Spark scripting API documentation. They have a lot more examples now, thankfully. After learning the JS basics, the next big step is getting familiar with the reactive style of programming that Spark uses. The reactive variables aren’t normal JS variables, so you can’t use standard code to check if/else, arithmetic, etc.

Here are some script resources that are worth poking around in.

@Tomas_Pietravallo learned JS in Spark, so he might have some tips for you :slight_smile:

1 Like

Wow. Thanks for the detailed answer.
As you say I will start learning js in general. Maybe I also have some applications for it outside of Spark. I found a good course on LinkedIn Learning.

I am a bit scared of these reactive variables. I have had a look on them in the past and was super confused. But maybe after some time and practice…

All the best and stay healthy! :slight_smile:

1 Like

Feel free to post your reactive questions here :slight_smile:

Signals are strange but there’s only a few concepts to learn

Yay a future programmer! Sorry, I’m deep into a project so I haven’t checked the lab so as frequently.

I learnt most of what I know in Spark, but I had some idea of what JavaScript was about — from KhanAcademy. You need less than you think, it could probably be explained on a Clubhouse room haha.

I learnt the rest from the Spark AR Documentation, W3 School, and MDN by Mozilla.

The best tip I can give you is: CODE! Don’t be afraid, try it, if you get error messages, google them, search for answers, but most important, don’t give up! Find some project/goal and don’t stop learning until you get there.

I’d suggest a getting some basic knowledge first, but after leaning about numbers/strings/arrays/functions you can give Spark a go.

The docs sometimes are incomplete, luckily the community has a lot of open source scripts you can take a look at, for example this one (contributed a small thing today): SparkAR-Snippets community repo.

I also have a medium difficulty tutorial: tomaspietravallo/sparkar-fdccc2020. If you are getting error messages (get comfortable with those**) that mention promises, check this section of the tutorial: async/await.

Remember you can always ask questions here or on the FB group! (Feel free to tag me).

I look forward to see what you create! Best of lucks :sparkles:.

** I say that not because it’s something beginners encounter, but because you’ll encounter them all the time, it’s not a bad thing/something to be ashamed of. Error messages are the way Spark/the compiler tells you something is wrong, you also get those in the patch editor and it’s no big deal, is it? If it’s of any help, I still get them and I’ve been coding for over a year in Spark + a bit more in other environments.


1 Like

Thanks a lot for the detailed reply @Tomas_Pietravallo ! :pray:
I have started the first lesson on Codeacademy now. I really like the UI and how its made in general. Learning there feels really intuitive. Only downside - If I want to continue I’ll have to pay $100 p.a.
Don’t know if that’s worth it.
W3 school seams a bit confusing to me. But maybe I will give it a try first.

I’ll let you know when I make some progress :wink:

1 Like

I haven’t taken their courses so I can’t help here — maybe it’s worth looking for some reviews. The important thing is that you come out with a clear idea of the general concepts (I’d say Data types & Async are the most important), which will allow you to start programming in real projects, don’t worry too much about syntax & typos, if you use VSCode that gets pretty much all taken care of (google VS Code Intelisense), but the computer can’t do all the work.
Please keep us updated! Best of lucks