- The examples below make uses of the log function of the console object present in most browsers for standard text output.
console.log(a); // 6
console.log(A); // throws a ReferenceError: A is not defined
- Local variables: Declare a variable inside of block or function.
- Global variables: Declare a variable outside function or with window object.
let globalVar = “This is a global variable”;
let localVar = “This is a local variable” ;
let localVar = “This is a local variable”;
After code run
! DOCTYPE HTML
<Title> A first script </Title>
- In script below, document.write is used to calculate the result of 5+6.
- You can include script at the end of document.