[SOLVED] What is the difference between let, const and var?

I’ve starting so llong ago coding, that 3/4 of all languages I’ve learned practicaly doesen’t exist any more ( Pascal, Basic, 8bit assembler, cobol, VB?, Cobol a.s.o. )
Th las Languages I’ve “learned” are Go and typscript…
Going back from TS To JS is getting quite hard…
TS expect to as you’re told and ersepect lint
back to JS I can do everything :slight_smile: :frowning:
/* in GoLang I only cast Float63 to Float 32 tot Interger depending on Package */

I say what I do, and everybode is welcome to correct me PLEASE

I do this.var = vfor scripts that runs in multi threads
I do var = v nearly never
I do let var = v seldom
I do v = for local var which can’t mess up wich other instances
( like v = this.entiy.root.Map.findByName(‘trasuers’:wink:
I do const as everyone else;

In VS.Code and typeScript I’m halfway sure I do right, but back to JavaScript i’m more unsure than ever before…
If anybody will supply a short answer whats “clean” coding, maybe with a hint onm the stack, so i can truly understand…

sorry it’s getting late, and I started get a litlle drunk because I can’t progress and won’t get to that code again :smiley:

chhers Gutki :cucumber:

PS: second thought… it’s because of prototype and func()…
where should I look to understand why Playcanvas use prototype instead of func?

var is supported in ES5 (so IE 11 and above basically) and is function scoped.

let (block scoped) and const (block scoped and cannot be assigned another value after declaration) is supported in ES6 which is supported in every modern browser for a long while now.

PlayCanvas ScriptTypes are created via pc.createScript() and it returns a class type that inherits from ScriptType.

This means that we patch or create new functions via the prototype property which is an ES5 way of creating classes. See JavaScript Classes, Inheritance, and Prototype Chaining (ES5 and ES6 Way) | by Kunal Tandon | Developer’s Arena | Medium and Object prototypes - Learn web development | MDN

solved ‘somehow?’