• Tutorials Logic, IN
  • +91 8092939553
  • info@tutorialslogic.com

Comments and Variables

Comments

Comments are annotations in the source code, which are ignored by the interpreter. So, comments can be used to prevent the execution of the statements or text in the source code. Whenever we want to ignore somthing from the execution in the source code, we use comments. Comments can also be used to explain complex code logic, so the other developers can understand easily. There are two types of comments in javascript, such as-

Single line comments:-

										    
											// This is single line comment
											document.getElementById("id").innerHTML = "Hello Tutorials Logic!";
											
										

Multi line comments:-

										    
											/*
											    This is multi line comment
											*/
											document.getElementById("id").innerHTML = "Hello Tutorials Logic!";
											
										

Variables

Variables are the containers in the memory which holds the data value and it can be changed anytime. In JavaScript variable can be declare by reserved keyword "var".

Standard Rules for JavaScript Variable Names:-

  • The variable name in JavaScript must begin with an english alphabet or the underscore character i.e.(A-Z, a-z, and underscore).
  • After first letter of variable name numeric character is allowed in the variable name i.e. (0 to 9).
  • A JavaScript variable name should not contain blank spaces.
  • JavaScript variables are case sensitive.
  • A variable name should not contain blank spaces.
										    
											var x = 5; // Number
											var Y = "Tutorials Logic!"; // String
											var Z; // Declared without assigning a value
											var x = 5, Y = "Tutorials Logic!", Z; // Multiple variable in a single Line