JavaScript Examples
This page contains JavaScript examples - examples of JavaScript tricks that you can use for your own website. You can use any of these examples by copying and pasting the code straight into your website.
Windows
Dialogs/Boxes
- Alert Box - onClick
- Alert Box - Unobtrusive
- Confirmation Box - onClick
- Confirmation Box - Unobtrusive
- Jump Menu with Conditional Confirmation Box - Unobtrusive
- Basic Prompt - onClick
- Basic Prompt - Unobtrusive
- Conditional Prompt - Unobtrusive
- "Print this Page" - onClick
- "Print this Page" - Unobtrusive
Dates
- Current Date/Time
- Current Date/Time - Locale String
- Current Date/Time - Locale String with Locale Examples
- Current Date - MM/DD/YYYY
- Current Date - DD/MM/YYYY
- Current Time - 24hr
- Current Time - 12hr
- Current Date - Long Format (e.g. Saturday, November 26, 2016)
- Current Date - Short Format (e.g. Sat, Nov 26, 16)
JavaScript Math
JavaScript Arrays
- Create an Array
- Concatenate Two Arrays
- Concatenate Three Arrays
- Join Array Elements into a String
- Remove last Element from Array
- Remove first Element from Array
- Add elements to the end of an Array
- Add elements to the beginning of an Array
- Sort Array Alphabetically (Ascending)
- Sort Array Alphabetically (Descending)
- Reverse an Array
- Extract Elements from an Array
Plenty of jQuery examples too!