Skip to content

Instantly share code, notes, and snippets.

@nifl
Created April 3, 2014 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nifl/9959442 to your computer and use it in GitHub Desktop.
Save nifl/9959442 to your computer and use it in GitHub Desktop.
JS Built-ins

Built–Ins

alert() Sends message to user in small pop-up window

confirm() Asks for consent to move forward. Cancel returns false, OK returns true

prompt() Sends a message and retrieves an entry.

typeof() Useful for checking a variable's contents

  • typeof true --> "boolean"
  • typeof "derp" --> "string"
  • typeof 42 --> "number"
  • typeof undefined --> "undefined"
  • typeof null --> "object"
var iceCream = prompt("What's your favorite ice cream flavor?");

typeof iceCream // Returns "object" if prompt() is set to null, ie, cancelled. 
                // Otherwise returns"string".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment