Discuss Scratch
- MegaApuTurkUltra
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Scratch JS Tutorial Forum
Then why is typescript not available on all devices? JavaScript is a great language.You know what else is available on all devices?
C

- MollTheCoder
 - 
                            
						
						
                            Scratcher
                        
						
						 
6 posts
Scratch JS Tutorial Forum
JS basics #1You do not need semicolons for everything, but some things might need them. JavaScript has an automatic semicolon system. But, some people consider it good practice to add semicolons.
JavaScript is a common programming language for web and game programming. It includes variables and functions. It is case sensitive.
You define variables like this:You have to put the semicolon at the end.var a = "hi";
You define functions like this:orfunction myFunction() {
code
}There are also alert boxes that use the alert() function, but that will be described more in JS basics #2.var myFunction = function() {
code
}
- Sheep_maker
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Scratch JS Tutorial Forum
Apart from the three statement for loop, semicolons also obligatory before lines that start with (, `, [, and *.
JavaScript will assume that you're trying to call 4 as a function, with the async arrow function as a parameter, which will throw an error since 4 is not a function
JavaScript thinks that you're calling a tagged template literal, but since 4 isn't a function, it'll throw an error
JavaScript assumes that you're trying to get a property of 4. It'll try to get 4[4] since the comma operator returns the final value, and since it's undefined, trying to get .forEach will throw an error.
JavaScript thinks you're trying to multiply 4 in the class field by some value rather than interpreting the asterisk as an indication of a generator function, but it throws a syntax error elsewhere because a curly bracket doesn't make sense when following a function call
Standard requires a semicolon before each line starting with those characters to prevent this except for the last case since class fields are fairly new
                        
                        
                    const four = 4 (async () => { await confirmIsFour(four) })()
const four = 4 `Four is also written as ${four}`.split('').forEach(char => { console.log(`**${char}** `) })
const four = 4 [1, 2, 3, four].forEach(num => { console.log(num * num) })
class Four { value = 4 * generateFourFours () { yield this.value yield this.value yield this.value yield this.value } }
Standard requires a semicolon before each line starting with those characters to prevent this except for the last case since class fields are fairly new
            

