Learn how to use JavaScript Comments, JavaScript Literals and JavaScript Identifiers:

Learn how to use JavaScript Comments, JavaScript Literals and JavaScript Identifiers:

First we will introduce you to comments style of this language. Mostly the comments style is same in some languages. You don’t mix the comment styles of various languages, it is necessary for you to know about how to write comments in JavaScript.

JavaScript Comments:

There are two styles of comments which are supported by JavaScript. First style is the one in which any text that you may put in between // and the end of each line is considered as a comment by JavaScript. This style is also known as Single Line Comment. Therefore this text is ignored by JavaScript. In the second style any text between /* & */ will be considered as a comment and will be ignored as well. You can use this style to enter paragraphs of comments in the code. Following are some examples of JavaScript comments:

//This is a first style of comment

/* This is a second style of comment */

/*You can enter the paragraphs of comment like this in your code.

*This style can be used to provide introduction of your program

*Or this style can be used to explain each instruction in your code.

*/

JavaScript Literals:

Any data which will appear directly in a program is known as a Literal. For your understanding we have provided various examples which are:

“i am a literal”                // A string of text

1989                               //The number is 1989

true                                // A Boolean value

null                                 // shows an absence of an object

{2,5,7,8,9,1,5,7,5}          //This is a way to initialize an Array

JavaScript Identifiers:

The identifier is basically a name. The words which are used to name variables, functions and labels of loops in JavaScript are known as Identifiers. You must remember that the identifier must start with a letter, dollar sign ($) or an underscore (_). The succeeding characters can be digits, letters, dollar sign or even underscore. You must remember that digits cannot be used as a first character of identifier. This rule exists so that JavaScript can differentiate between numbers and identifiers. You should notice the following legal identifiers:

you

i_am_blog

exercise14

_what is an identifier

$your

To make the code editing easy and portability the ASCII characters are usually used as in identifiers. But what if you want to use a mathematical symbol as a variable! To solve this problem, you can use letters and digits from an entire Unicode set in identifiers. Due to this, you can also use variables names from non-English languages. Following is example of mathematical symbol identifier:

var π = 3.14;

var ∑ = 4.2;

In this post, you have learned about comments, literals and identifiers in JavaScript. To Learn more about JavaScript subscribe to our RSS feed and newsletter and you will be expert in JavaScript in no time.

To get a mobile app for your business visit www.codescamp.com

Book a free consultation today!

email

9 Responses to Learn how to use JavaScript Comments, JavaScript Literals and JavaScript Identifiers:

  1. I just want to say I am newbie to blogging and seriously savored you’re page. More than likely I’m likely to bookmark your blog post . You absolutely have fabulous stories. Kudos for revealing your web-site.

  2. Just Browsing

    While I was browsing yesterday I saw a excellent article about

  3. ntc 249 says:

    Its hard to find good help

    I am forever proclaiming that its hard to find quality help, but here is

  4. May I simply just say what a comfort to uncover someone who truly understands what they’re discussing online. You certainly realize how to bring an issue to light and make it important. More people should read this and understand this side of your story. I was surprised that you are not more popular since you most certainly have the gift.

  5. You can certainly see your skills in the work you write. The world hopes for more passionate writers like you who are not afraid to say how they believe. Always go after your heart.

  6. buty damskie says:

    You have made some really good points there. I looked on the net for more information about the issue and found most individuals will go along with your views on this web site.

  7. I’m still learning from you, while I’m making my way to the top as well. I certainly love reading everything that is posted on your blog.Keep the information coming. I liked it!

  8. Magnificent beat ! I wish to apprentice while you amend your web site, how can i subscribe for a blog web site? The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast offered bright clear idea

  9. auto mobil says:

    Hiya, I’m especially pleased I’ve establish this info. Today bloggers publish only concerning gossips and clear and this is really frustrating. A good position with exciting pleased, this is what I hardship. Thanks for keeping this website, I will ensue visiting it. Perform you do newsletters? Cant get back it.

Leave a Reply