- Javascript was created to be used on the browser alongside HTML and CSS
- With Node it can be used on servers
- It is lightweight, interpreted and has first-class functions
- Javascript and ECMAScript are interchangeable names, we'll use ES6 onwards
Loosely based on java, lots of {} and ()
//Comments like this
/* Useful for remembering things
or explaining something to a different person
or just not using something a piece of code for a while
Variables: Labeled/named storage for any value we want
Let : keyword
= : assignment operator
//Declaration:
let welcome;
let a, b, c;
//Initialization
welcome = 'Hello Ironhacker';
//Declaration and Initialization
let welcome = 'Hello Ironhacker';
// Change values later with let
welcome = 'Hi there';
console.log(welcome, typeof welcome);
welcome = true;
console.log(welcome, typeof welcome);
//Since Js is dynamically typed we can change the type of a variable, which isn't always good
Const:
//Const is used when we know the value won't change
//They need to be declared and initialized immediately
const planet = "Earth"
const city; <= Error
- Camelcase and some reserved keyworkds (let, var, return, class, function....)
- Use Meaningful names
- Use human readable names (firstName, lastLogin)