Should we teach kids var or const and let or both?

Sort of an unusual question - because we are asking you!!

ZIM Kids is still using var.

We are about to change that over... I think... to const and let. What do you think? It is so annoying to have to start with them with the nuances of const and let. Not that it is that hard... but it was easier. Another option we could do is just change everything to let. But that does not seem quite right. Any suggestions?

You can find some of the lessons in Magic - ZIM Kids - Coding Workshop, Lessons, Tutorial, Camp, School but then each workshop also is filled with vars...

Here are my 2 cents: Leaving the intricate explanations of memory management, and garbage collection, I would go with only "let" at first (it's even more English than var), then introduce "const" in the rare cases you really want a constant, i.e. don't want a variable to be changed by mistake.

1 Like

All three of them serve a purpose. If you are teaching them basic JavaScript and how it interacts with the document var is really all you need; IE beginner courses.

If you are going to teach them objected oriented applications with any sort of scaffolding you will want to use con, this, and let; IE advanced courses.

1 Like

I primarily used typescript over javascript 99% of the time. const and let are ideal for preventing problems that are beneficial to objected oriented design. But it's really due to the IDE identifying any offense to the const being changed instantly. However, does this exist in javascript or the type of IDE environment or does it require an error in the console at runtime to discover the offending line of code?

I would say var with javascript could make more sense for kids to reduce the interruption in the flow of progression for an individual. Although, I believe its certainly serves its purpose in more advanced javascript usage.

One more thing to consider. Are kids using the resource sequentially? If it's quite often used out of order then it may be a bit jarring to encounter different material using the keyword without an introduction or explanation. So with that in mind, I would say let and const may need an early introduction.


@karelrosseel82 you are teaching - what do you think? var or const and let or both?

let and const
NOT var

let AND const!
const is a VERY important concept - immutability imposes discipline that should be understood from the start. You can always eschew it later under duress.

var itself creates confusion and violates pretty much every structured programming principle

teach var later as how the cavemen (scriptkiddies) of the Web dis-organized their work

1 Like

We have now converted to const and let

Are you teaching kids how to program in general? Here's some quick let vs. const code that demonstrates when you might use each...

const fruits = ["Apple", "Banana", "Coconut"];

for (let i = 0; i < fruits.length; ++i) {

for (const fruit of fruits) {

let i = 0;
while (i < fruits.length) {
1 Like