Skip to content

Instantly share code, notes, and snippets.

@dannyfritz
Forked from bertoort/intro_to_js.md
Last active July 17, 2017 20:46
Show Gist options
  • Save dannyfritz/e81b2d3aff8dfbe94377695296e837a6 to your computer and use it in GitHub Desktop.
Save dannyfritz/e81b2d3aff8dfbe94377695296e837a6 to your computer and use it in GitHub Desktop.

Intro to Programming with JavaScript

Standard

Write, mentally evaluate, and store the result of JS expressions

Objectives

  • Describe what a programming language is
  • List reasons for learning JavaScript
  • Run JavaScript with a REPL
  • Use the various types in JavaScript
  • Determine the type of something with typeof
  • Perform math with arithmetic operators
  • Compare values with comparison operators
  • Read/write values from/to a var
  • Write some code that will not be interpreted with a comment

Programming Languages

Q: How many programming languages can we name as a class?

Q: What do programming languages solve? A: Many things, depends on the language.

Q: But what is it really? A: A language written for humans to execute commands on a computer

  • Let's look at some language examples and infer things about them from the syntax.

Pair up and look at some more code examples on Rosetta Code


JavaScript

Why learn JavaScript

Why learn JavaScript?

  • Only language natively supported by browsers
  • Popularly used on both the client and server for the web
  • It is ubiquitous
  • Sustained adoption
  • Low barrier to entry

History of JavaScript

  • Developed in 10 days in 1995 by Brendan Eich while working for Netscape.
  • JavaScript version history
  • TC39
  • ECMAScript and JavaScript

Using JavaScript

Running JavaScript in a REPL

read–eval–print loop

Using the snippets section of the Chrome Dev Tools.

Types in JavaScript

What are some types you can think of?

JavaScript has 7 types:

  • string
  • number
  • boolean
  • null
  • undefined
  • Object
  • Symbol (new in ES2015)

typeof


Operators

Knowing the types available in JavaScript, what are some things you would want to do directly with them?

Arithmetic

  • +, -
  • *, /
  • %
  • ++, --

Play around with arithmetic operators with a partner.

Comparison

  • ==, === (strict)
  • >, <, >=, <=
  • !=, !==

Partner up and try some of these comparison operators out. Try them on the same type, different types, etc.

Show the wat video.

Operator Precedence

When is this important to know about?


Variables

  • var
  • = assignment

Play around with variables with a partner.

Have you thought about how you would name variables?


Comments

  • //
  • /* */

Pair up and find an open source project. Find some interesting comments and discuss them.


Review

  • Describe what a programming language is
  • List reasons for learning JavaScript
  • Run JavaScript with a REPL
  • Use the various types in JavaScript
  • Determine the type of something with typeof
  • Perform math with arithmetic operators
  • Compare values with comparison operators
  • Read/write values from/to a var
  • Write some code that will not be interpreted with a comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment