7 Comments in Javascript – JS for Beginners

Last updated on October 31st, 2020 at 06:33 am.

This video is taken from the full course that will teach you HTML, CSS, Programming concepts and Javascript .

Video Transcript:


Okay, so like any other programming language, you’ll find yourself using comments in JavaScript.

And there are single-line and block comments.

So a single-line is just two forward slashes.

And then for a block comment, it is one single forward slash, an asterisk and an asterix and a forward slash.

So if I want to add a comment here, I can just add it there with forward slash there.

That’s a comment.

That’s a single-line comment.

And this will not be executed.

It is just a comment that will let someone else reading the code know what’s happening.

So that’s a single-line comment.

You can also have, you can also have the block comment.

So there.

So comments are useful.

They can help you understand what it is that you’re doing, especially when you’re writing lots and lots of code.

You can use comments to explain what you’re doing so that when you come back to the code in future, you will know what it is you were trying to do.

Because in most cases, you’ll find you write a lot of code and if you write a lot of it and there’s no way for you to remember what it is you were trying to do, you’ll have a hard time trying to figure out what exactly that code does.

So you can use comments, by single lines or you can use a block comment such as this one.

Let’s continue in the next video.

This section is from Learn Javascript from Scratch.

Learn Javascript from Scratch

Comment Here