An introduction to JavaScript

October 14th, 2014

By Arne Hassel

Overview

  • Why learn JS?
  • Examples of applications
  • Coding
  • Tips

Why learn JavaScript?

  • Just another programming language?
    • How does it compare to other programming languages?
  • (Isn't it really, really messy and unstructured!?)

Just another programming language?

  • De facto programming language of the (front-end) web
    • Supported by all major browsers
    • (Is getting more popular on the back-end as well)

Compared to Java

Feature Java JavaScript
Objects Classes Prototype-based
Interpretation of code Imperative Imperative
Functional Yes Supported-ish
Type system Static, nominative Dynamic
Browser support Plug-in Native

(Note: List is not exhaustive)

Complexity

Examples of applications

Webpages/Apps

Games

Data visualizations

Robots!

Let's code!

Syntax

  • Variables
  • Functions
  • Objects
  • Arrays

Variables

Example

Functions

Example

Objects

Example

Arrays (lists)

Example

Utilizing JS in webpages

  • Inline code
  • Script tags
  • External files
  • Progressive enhancement

Inline code

Example

Script tags

Example

External files

Example

Progressive enhancement

Example

Lets create a clock!

  • Using "pure" JS (-ish)
  • Using jQuery
  • Using AngularJS

Using "pure" JS (-ish)

Example

Using jQuery

Example

Using AngularJS

Example

Some final tips

Thank you!