Learning grammar for a spoken language is necessary before you start writing it. There are rules and regulations you have to follow to write. Similarly, all programming languages have their grammar/syntax and rules which you have to follow in order to execute.
- In this statement “alert” is case sensitive and if I change the first letter of “alert” “A”.
- Built-in objects such as math and date are uppercase or capitalized.
- DOM(Document Object Model) are usually lowercase but the methods are often a combination of lowercase and uppercase.
Variable, Function & Objects Name
- You can define or name your own variable, function and objects.
- There is no limit in choosing their name you can use uppercase, lowercase and underscore(_) or Numbers.
- The name must begin with letters or underscore and it can’t start with a number i.e getAgeBy_Name, getHeightUnder_2
- So make sure to use the same variable when calling it or referring.
- Statement can be used to change the color of webpage, background or position of picture etc
- White space is not sensitive. You can add spaces and line-breaks as much as you want.
- Single Line Comment
- Multi-Line Comments
Single Line Comment
Single line comment represents double slash forward (//). You can use it before and after the code. When you add these two forward slashes (//), all of the code/text to right of them will be ignored. You can see an example in the below picture.
The multi-line comment is more convenient than single-line comment, you can use it as a single line comment and multi-line too. Multi-line comment represents forward slash with stearic /* and end with a stearic forward slash */.
/* Your comment here */
You can out a segment of code by adding multi-line comment in it. You can look in the image for more detail. These are so helpful in coding. You can add any comment at any time as you want for your preference. Look in the below image for a more clear example.
- Number: Number represents all the integer, decimal and float type etc. i.e 4, 4.345
- Boolean: Boolean is going to store if the statement is true or false. True/false
- String: String should be either in a single quote or double-quotes. “I am learning Js” ‘Mystring’
Google Chrome Development Tool
- Google developer tool is available in the google chrome browser. Since you all know the google chrome browser already. So move forward.
- Hence, all you have to do is press f12 in your google chrome browser. It will bring a tab like this as you can see on the right side of the Image.
It will take you to the element bar, you can go to the console bar by clicking on it.
- Element tab shows the HTML of the page.
- Open a new tab in your browser and press f12.
- Now go in console tab and type this code:
alert(“I am doing this alert form in console”);
And press enter. Then the dialogue box will appear instantly. Don’t worry about this “undefined message”.
- You can type different numbers in here and get your result, addition, multiplication, subtraction and more. See in the image.
- Now go back in element tab and you can see the console panel in the last. Look in image:
If you want to learn any other language comment below. We will make sure to share those languages with you too.