JavaScript

TotT: 2014

JavaScript

"JavaScript is a prototype-based scripting language with dynamic typing and first-class functions."
- Wikipedia

Major Attributes

  • C-derived syntax
  • Runtime interpretation
  • Dynamic typing
  • First-class functions
  • Prototypical inheritence
  • Garbage collection
  • Rich literal types

Use Cases

  • Embedded scripting
  • Frontend web development
  • Backend web development

Example: Factorial

Example: Sine/Cosine

Example: Mammals

Example: Evens

Example: Timers

Example: Cycle

Gotchas

  • Function scope
  • Automatic semicolons
  • No true methods
  • No import statement
  • No multiline strings
  • Weird operators

NodeJS

  • New, circa 2009
  • Run JS server-side
  • Uses Google V8 JS engine
  • Small standard library
  • Event loop, async I/O

Demo: Working with NodeJS

Demo: Working with NodeJS

Review

  • Language Features
  • Syntax
  • Types
  • Prototypes
  • Function Closures, Callbacks, Parameters
  • NodeJS
  • Gotchas