JavaScript Syntax

Javascript language is case sensitive which means that it strictly operates within a declared and predefined set of rules. A javascript syntax is something that should be exactly as it is in a written statement.

For example:

var x, y, z; //declaration
x = 10;  //Assignment
y = x;
z = x/y;   //operator operation
  • Any variable which is declared must be with the keywords var, let, and const.
  • An equal sign represents that it has been assigned a value.
  • Always use the precise keyword as it is defined already.
  • We cannot define VAR or Const or LEt like this as it will throw an error and simply won't interpret it to its default keyword.
  • As we said javascript is case sensitive which means you got to give the exact variable with the respective name without altering its keyword.
  • Javascript follows the Unicode character set which sort of covers almost all the characters, punctuations, and symbols in the world.
  • We cannot use hyphens in a javascript syntax as it is reserved for subtractions.

Javascript CamelCase:

  • We have upper camel case or otherwise called pascal case¬†
FirstName, LastName, MasterCard
  • The lower camel case tends to start with a lowercase letter and the second word starts with uppercase.
firstName, lastName, masterCard

Literals:

  • In javascript just like any other language, numbers are written with or without decimals.
20.66
2066
  • Strings can be written within both double and single quotes.
"Rob"
'Rob'

Operators:

  • Javascript uses arithmetic operator(+-/%^) to compute values and arithmetic operations.
(5/10)*50
  • It uses an assignment operator(=) to assign values to the variable.
Mon, 09/13/2021 - 08:39

Authored by

Ashwin is working with iVagus as a Technical Lead. He has experience in various technologies like Cypress, JavaScript, TypeScript, Rest Assured, Selenium, Cucumber, and Java.
Tags