Students Empire

Learn Something New
Home

Block Element


Multiple statements can be combined into a code block by using C-style syntax, beginning with { and ending with }:

				if (test){
				   test = false;
				   console.log(test);
				}
				

The best practice is to use code blocks with control statements, even if there's only one statement.

				if (test)
				   alert(test);     //valid, but error-prone and should be avoided

				if (test){           //preferred
				   console.log(test);
				}