● Writing into an HTML element, using innerHTML(‘’)
{document.getElementByID(xyz).}
● Writing into the HTML output using document.write()
● Writing into an alert box, using window.alert()
● Writing into the browser console, using console.log()
● To print the entire page window.print()
One line comment // xyz
Paragraph comment /* xyz */
Variables
● Const x = 5; (constant value)
● Let x = 5 ; (varied value)
● Var x = 5 ; (for old browsers)
Scope Redeclare Reassign Hoisted Binds This
var No Yes Yes Yes Yes
let Yes No Yes No No
const Yes No No No No
The general rules for constructing names for variables (unique
identifiers) are:
● Names can contain letters, digits, underscores, and dollar signs.
● Names must begin with a letter.
● Names can also begin with $ and _ (but we will not use it in this
tutorial).
● Names are case sensitive (y and Y are different variables).
● Reserved words (like JavaScript keywords) cannot be used as
names.
Reassigning a variable overwrites the original value of that variable
$("p"); means "select all p elements".
Shift assignment operators for larger values