5. JavaScript Tutorials | Statements and comments

Share this post on:

hey what’s going on guys then Maya for Telesco learnings and in this video tutorial we’re going to be understanding what are statements and what are comments in JavaScript so there’s going to be a very quick short video because this topic is not that big but definitely it is under our curriculum and we’ll just quickly go add in the programming part directly so in the previous video we ran our first program that is the hello world program and if you have missed that video you can check it out so as you can see on the screen on the right hand side we have our visual studio code running and this is our bare bone structure of the HTML document and here you can see in the script tag we have embedded our first line of JavaScript so this was something that we did in the previous video as well so coming to our topic of statements now in general whenever you are using any kind of programming language essentially what you’re doing is you’re giving some instructions to the computer to perform certain tasks and perform certain activitiesfor you right so this is something which is common among all programming languages so now these statements are pretty much what is known as instructions to the computer so if you come to this JavaScript code you written over here this document dot right and inside this opening and closing round brackets for degree we typed is basically an instruction to the browser to execute this code and to print out hello world on the screen right so this is exactly an instruction for the browser so yes this is a javascript statement so again statements are instructions to the computer or to the system to perform certain activities now we can have many statements in one single program

obviously, we’re not going to write only one line of code so we’re going to be performing multiple activities so you

can have multiple statements and the way we separate statements is by using a semicolon so you can see over here the semicolon separates this statement and let me just copy this entire line and hit enter and again paste it so now we

have two different statements which are separated by semicolon so I’m going to see the h2 tag over here so let’s print out

h2 tag and inside this, we will say Telesco learning’s just save this and refresh this and there you go you can see now two things are printed so we have one h1 tag being printed which has hello world and other one is Telesco learning so as this was just a little bit of explanation on what Asti mints in JavaScript or in any other programming language and as I mentioned we can have n number of statements they just need to be separated by a semicolon and you can have a sequence on one single line as well so if I paste one more line over here you can see this is completely

valid if I save this and run this we will have three outputs if I take this in the next line it will be considered the same just that it has to be separated by semicolon now we can have multiple things in statements we can have variables we can have function calls we can have something running in the background or some doing some other tasks and whatnot you know you can have something that is performing some animations and so on and so forth, of course, we haven’t discussed variables datatypes functions and we will be covering that in further videos so that’s why I have not included anything over your but yes you get the point right anything that is performing certain tasks is a statement in

JavaScript now coming to the comments so comment is a line in programming in JavaScript or in any programming that does not have any effect on the program so a single line comment starts from double slash so you can see double slash over here for double slash and you can see this is a comment if I see you this and if I run the document or reference the HTML document again you can see there is nothing happening over here because this is a comment and it doesn’t affect how the program runs okay how JavaScript runs so you must be wondering

why do we need comments so in the general comment is just added to remind the programmer of what the activities are happening so just beside this document dot to write I can see in a comment that we are printing hello world so this is just a note for the programmer so that he

remembers what he is doing in the program now this is irrelevant when you are typing very small code let’s say you’re writing ten lines of code and after 20 days you come back and again read through that you’ll easily understand but in real-world scenarios when you’re writing like hundred lines of code 200 lines of code or even more than that in that case if you write a finite line of code and come back 20 days and again go through that code you’ll be like oh my god what is this right so you’ll be confused so that’s

where comments come into the picture and it is a very good habit to always have comments wherever necessary so this was a single line there can be multilingual so let’s say you want to comment out all these three

lines together so you start off with forwarding slash and you see the star and then to end the multi-line comment you against a star and forward slash so anything inside this is gonna be a multi-line comment okay so if I cut this and paste it over your anything in this space is gonna be a multi-line comment, okay you can have anything over here you can type anything and this is all a multi-line comment and it will not affect your program so yeah this was it

for this video but I do have one question for you I need your feedback so as we move ahead in this entire series

we’ll be using this Visual Studio code ID a lot so I just wanted your review on which color theme should we go-ahead

with now as you can see on the screen we are using a dark theme but we also have other color themes so let me just show you those color themes so if you go in the settings in the color theme you can choose a light theme as well so you have two options of going out with this light theme and you can go with the current one which is a mono pie which we’ve been using now there are different other themes also but they don’t look really good so I just wanted your feedback as to which color theme should we go ahead because then I’ll be using that same

the color theme throughout this entire series when we are going to be programming and the reason why I’m

asking you this is because although this black theme looks very geeky and very cool on video sometimes what happens is that text is not clearly visible so when you’re using a white or light theme at that time that text is very bold and clear so I just wanted to know what your feedback is so this is my view let me know in the comments which color theme should I be using and don’t go with the cool looks and cool feel just consider

what is more clear to you in the video and do let me know in the comments which theme you would like so that’s it for

this video guys in the next video we will cover some more JavaScript syntax concepts and practical aspects of

JavaScript thanks for watching see you guys in the next video peace.

Share this post on:

Leave a Reply