• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details

Return the last element in an array

Return the last element in an array

Use Array.prototype.length – 1 to compute the index of the last element of the given array and return it, otherwise return undefined.

Miscellaneous

JavaScript Booleans Explained

JavaScript Booleans Explained

A boolean value is one that can either be TRUE or FALSE. If you need to know “yes” or “no” about something, then you would want to use the boolean function.

Basics

Copy text to the clipboard

Copy text to the clipboard

Assume that we want to copy a given text to the clipboard. Here’s how.

Miscellaneous

Apply a CSS animation to an element with JavaScript

Apply a CSS animation to an element with JavaScript

A helper function to apply a CSS animation to an element with JavaScript.

CSS

Confirm Yes or No With JavaScript

Confirm Yes or No With JavaScript

How to display a confirm dialog box using JavaScript. The confirm dialog box allows you to perform actions based on the user input.

Miscellaneous

Round a number to a specified amount of digits

Round a number to a specified amount of digits

Use Math.round() and template literals to round the number to the specified number of digits. Omit the second argument, decimals, to round to an integer.

Math Related

JavaScript Strings Explained

JavaScript Strings Explained

In JavaScript, Strings are values made up of text and can contain letters, numbers, symbols, punctuation, and even emojis!

Basics

Calculate the size of scrollbar

Calculate the size of scrollbar

The clientWidth property indicates the width without scrollbar. The offsetWidth, on the other hand, includes the scrollbar if there is.

Page Details

Automatically expand a textarea as the user types

Automatically expand a textarea as the user types

A really neat little helper function that automatically expands a textarea as the user types in.

Forms

How to Add and Subtract Time From a Date in JavaScript

How to Add and Subtract Time From a Date in JavaScript

How you can add time to a Date object and subtract time from a Date object in JavaScript.

Time & Date

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 20
  • Go to page 21
  • Go to page 22
  • Go to page 23
  • Go to page 24
  • Interim pages omitted …
  • Go to page 36
  • Go to Next Page »

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers