Summary of what JavaScript (JS) is and is not;

  • JS is a client-side, object-based, case-sensitive language. Whose interpreter is embedded  in the web browser software.
  • Variable names, function names must avoid JS keywords, reserved words and object names.
  • For JS code each opening HTML <script> tag must assign a MIME type of “text/javascript” to its type attribute
  • Script block can have single line or multiple line comments
  • Each JS statement must end with a semicolon.
  • Inline JS code can be assigned to any HTML event attribute such as onload, or enclosed within a <script> element in the document body section.
  • All JS code is best located in an external file whose source is specified to a src attribute of the <script> tag.
  • Unobtrusive JS places all script code in an external file and can specify a function to the window.onload DOM property to set behaviours when the HTML document loads.
  • JS variables are declared using the var keyword and can store any datatype – boolean, number, string, function or an object.
  • JS functions are declared using the function keyword. and the function name must have trailing parentheses followed by a pair of braces {} enclosing statements to execute.
  • A function declaration may specify arguments within its trailing parentheses that must be passed from its caller.
  • A value can be returned to the caller using the return keyword.
  • Local variables declared inside a function are only accessible within that function.
  • Global variables declared outside functions are accessible from within any function within that script.



Source: JavaScript in Easy Steps