Comments on programming languages and HTML - 17

- Andrés Cruz

En español
Comments on programming languages and HTML - 17

Comments are the mechanism we have to leave notes in our program, and the character or set of characters that we can use varies depending on the programming language we are using; in JavaScript they are represented by a pair of consecutive slash (//) to place comments on a single line.

and in the following format to make comments in multiple lines, comments have many functions; but their main objective is that they allow us to leave notes or help to other programmers or to ourselves who are working with our code in which we explain the objective of what we are doing.

Comments are simply one or multiple lines of text that the compiler or interpreter ignores when compiling or interpreting the code.

This is basically how any compiler works today, which basically allows you to translate from one language to another; in our base of interest, from a programming language such as Java, C, C++, etc. to a machine language, that is, to a binary; pure zeros and one that is the only thing our computer understands; Therefore, in practice, when the compiler // simply does NOT take them into account, they will NOT be part of the compilation or the binary code generated by the compiler.

Examples of comments

Comments on multiple lines

In most programming languages, we can define multiple comment lines using /**/; in JavaScript, Kotlin, Java... they work based on this scheme:

/*
This is a comment
on several lines
*/

In Python we can use the following scheme:

"""
This is a comment
on several lines
"""

Single line comments

The traditional or simplest ones would be to place comments after the two slashes:

// Comment in a single line, we use it in JavaScript, C, Java...

And in Python we have to use the numeral # instead:

# comment in python

Comment in HTML

In HTML, being a language (and not a programming language) of tags, things change a little and we can create comments on several lines as follows:

<!-- 
HTML Comment
We can place as much content as we want
-->
Andrés Cruz

Desarrollo con Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz en Udemy

Acepto recibir anuncios de interes sobre este Blog.