•Start with letter or an underscore character and dollar sign•Can contain letters, numbers, underscore and dollar sign.•Variable names are case-sensitive•Use either underscore or Camel Casing to name a variable with more then one word•let first_name or let firstName•Use meaningful names (gagleegoo !!!!! Is not meaningful)Primitive data types•There are 6 primitive data types in JavaScript•Boolean— true or false•Null— no value•Undefined— a declared variable but hasn’t been given a value•Number— integers, floats, etc•String— an array of characters i.e words•Symbol— a unique value that's not equal to any other value•ObjectJavaScript Comments•Single line comment //•Multiple line comments /* … */Window and Document Objects•window.alert(123) or alert(123)•let num = prompt(‘enter a number’, 10)•print() <a href=‘#’ onclick=‘print()’>Print this page</a>•window.location ( •window.open(‘’);•Document object•document.write(value) or document.writeln(value)Syntax error and logical errors- is when something is misspelled logical error – when there something that doesn’t make sense
Chapter 2 How to code JavaScript-Using a text editor like Notepad++ or TextWrangler, enter and edit XHTML, CSS, and JavaScript filesHow to load JavaScript from an external file<script type="text/javascript" src="sales_tax.js"></script>Scr = the file name