Skip to content

Instantly share code, notes, and snippets.

@MrAFerreira
Created March 13, 2023 17:32
Show Gist options
  • Save MrAFerreira/fc3029851561a8c11f39d0e8a142f097 to your computer and use it in GitHub Desktop.
Save MrAFerreira/fc3029851561a8c11f39d0e8a142f097 to your computer and use it in GitHub Desktop.

Javascript Intro | Lesson



  • 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

Syntax (brief recap)


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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment