Understand the basics of JavaScript Lexical Structure or Syntax

Understand the basics of JavaScript Lexical Structure or Syntax

Today, you will learn in detail about the lexical structure of JavaScript. The lexical structure of any programming language means the set of rules that explains how to write code or program in that language. Therefore, for new programmers like you, learning the lexical structure of any programming language is the first step. Moreover, the Lexical structure is also known as Syntax of the programming language. Therefore, for simplicity we will use the term SYNTAX throughout the tutorial. The first thing you need to know is a character set.

JavaScript Character set:

The Unicode character set is used to write JavaScript programs. You should know that Unicode supports every programming language on this earth & it is a superset of ASCII and Latin 1.

JavaScript Case Sensitivity:

This language is a case sensitive. In other words, the JavaScript variables Moon, MOON, MoOn etc are all considered as a different variables and can have distinct values stored in them. Same is the case with functions names, keywords and identifiers as well.

Confusion between JavaScript, XHTML and HTML case sensitivity:

You should notice that the XHTML is case sensitive, But HTML is not case sensitive. Therefore, for you being a new programmer it can be a little bit confusing. Another reason for the confusion is that the HTML has close association with the client side JavaScript. But with practice you will understand. For example there are various client side JavaScript objects and HTML Tags have the same name. i.e. these names can be written in any case in HTML, but in JavaScript they have to be case sensitive.

For better understanding consider the event handler named onclick of HMTL. This is sometimes written as OnClick or onclick in HTML because it is case insensitive. But this same attribute must be written only as onclick in JavaScript.

Line Breaks and White spaces in JavaScript:

The line breaks means that the command that terminates the line in a code and moves to the start of next line. The white spaces are basically the blank spaces in between the words. All those spaces that appear between the tokens in the programs are ignored by JavaScript. It mostly ignores the line breaks in the code as well.  This is useful for you, because you can easily create a neat and consistent piece of code by formatting and indenting freely. In other words, you can use as many spaces and free lines you want in your code to make it readable.

JavaScript usually considers following as a whitespace characters:

  • Tab
  • vertical tab
  • form feed
  • non breaking space
  • byte order mark
  • any character in Unicode  group

JavaScript considers following as a Line breaks or terminators:

  • line feed
  • carriage return
  • line separator
  • paragraph separator

You need to remember that the line feed and carriage return are considered as a single line terminator

Format Control Characters:

These characters controls the presentation of the text they occur in. For example, RIGHT-TO-LEFT MARK &  LEFT-T-RIGHT MARK. These characters are significant for the presentation of non-English languages. You should remember that they are allowed in comments, expression literals and string literals. But they are not allowed in identifiers like name of variables etc. Except, the ZERO WIDTH JOINER & ZERO WIDTH NON JOINER are allowed in identifiers but not in the first character place.

So, in this post you learned about Case Sensitivity, white spaces, line breaks and format characters of 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!


5 Responses to Understand the basics of JavaScript Lexical Structure or Syntax

  1. I just want to tell you that I am beginner to blogging and seriously savored this web page. More than likely I’m likely to bookmark your website . You certainly have outstanding well written articles. Regards for sharing with us your website page.

  2. Hey there! I simply would like to give you a huge thumbs up for your great info you have right here on this post. I’ll be returning to your site for more soon.

  3. Good day! This post could not be written any better! Reading through this post reminds me of my previous room mate! He always kept chatting about this. I will forward this page to him. Pretty sure he will have a good read. Many thanks for sharing!

  4. Amado Mcbath says:

    Hey there! Would you mind if I share your blog with my myspace group? There’s a lot of folks that I think would really appreciate your content. Please let me know. Thank you

  5. penny stock says:

    We are a bunch of volunteers and starting a brand new scheme in our community. Your website offered us with valuable info to work on. You have performed an impressive job and our whole neighborhood can be grateful to you.

Leave a Reply