Notes For Stupid Browser Tricks Day 1

Various Built-in JavaScript Functions We Covered

  • alert("Help Me!!! I'm trapped in an alert box!");
    • Alert rings the bell and pops up a window of information
  • prompt("What's Your Sign?", "Neon");
    • Prompt asks a question (“What’s your sign?”), and then adds a prompt (“Neon”) as a possible answer or hint as to how to enter the box
    • Prompt will return what the user types in the input box
  • confirm("Can I move on now?");
    • Confirm asks a question (“Can I move on now?”), and returns either  a
      • true (if ‘okay’ was pressed)
      • false (if ‘cancel’ was pressed)

Objects in JavaScript

JavaScript is like PHP, ActionScript, or Python in that it can be coded as a top-down, procedural language (run one statement at a time, working your way from top to bottom) or it can be coded using the Object-Oriented Programming (OOP) paradigm. This makes JavaScript one way for a teacher to introduce Object-Oriented Programming in small chunks. When it comes to browsers, JavaScript has some built-in objects that make working with web pages very handy.

The three objects introduced yesterday were:

  • document – The document class refers to web pages. Every web page has properties and methods.
  • navigator
  • date


Anatomy of a Function & Function Calls