Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Device agnostic javscript – Part 2

Thursday, July 24th, 2014 by Servage

JavaScript-2

In part 1, we covered the fundamentals of JavaScript and now we will proceed with the basic ideas of JS syntax. JavaScript is similar to other modern languages in the way sentences are constructed.

JavaScript Syntax

The major components of JavaScript syntax include the following:

  • Literals: in any programming language, there are constant values which may appear as numerals (Number Literals) and as words in single/double quote (String Literals).
  • Variables: means data containers that store information. You can assign a value to the named variable using = (equal sign).
  • Operators: with these you can compute values, as you do in math. You can also assign computed values (operators) to a named variable and can use expression literals with the help of these operators.
  • Statements: the sequence of a computer command is termed as a statement of language. In JavaScript, they are separated with semicolons at the end of each statement.
  • Keywords: a JS statement begins with a word that is called the keyword. This may be a variable, function, string or anything else.
  • Comments: In any language, comments are essential to comprehend the code and remember the context of a particular code string where they are specifically written. In JavaScript, double slashes // are used for single line comment while slash and asterisk /* are used for multi-line comments.
  • Data Types: Usually JS variables hold different types of data, such as: numbers, text strings, array, objects, etc.
  • Functions: In order to compact code and omit repetition, some sentences are written in a function format, with all sorts of computer languages at once. Later, these are called on by defined functions whenever needed by invoking them in any statement to accomplish certain tasks.
  • Identifiers: If any programming language cannot identify its variables, functions, and objects with unique names, there is a good chance it will lead to confusion. Therefore, identifiers or unique names in JavaScript are used to ease the task at hand. They are often made up of letters, digits, underscore signs, solar signs and more symbols. Identifiers never use numbers or reserved words (keywords of JavaScript).

Peculiarity of JavaScript Syntax

JS is a case-sensitive language or script, so all identifiers are case-sensitive and differ with slight changes in capital to small letters. JavaScript’s high acceptability is due to using the Unicode character set, where almost all characters, punctuation, and symbols are supported across all browsers, regardless of device type.

Coding JS is easy as you can differentiate statements using a semicolon (;). You don’t need to write each sentence on separate lines, especially if they are a shorter length. Another peculiarity of JS comes from it being executed in the sequence in which it is written. Similar to how making code blocks are easy using curly bracket ({…}). This block formation simplifies statement execution, making it appear together in a sequence. Defining JS functions are therefore mostly done with block formations. In JavaScript, statement identifiers are reserved words, so we can’t use them as variable names or in any similar way.

 

References & More Reading
JavaScript Syntax
Learn to Program with JavaScript

Device agnostic javscript - Part 2, 3.0 out of 5 based on 3 ratings
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.