• 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

Check if an Item Exists in an Array

Check if an Item Exists in an Array

Instead of using the indexOf() method to check if an element is in the array, you can use the includes() method.

Miscellaneous

Find the distance from a given element to the top of the document

Find the distance from a given element to the top of the document

Use getVerticalOffset to find the distance from a given element to the top of the document.

Page Details

Create a custom scrollbar

Create a custom scrollbar

You can customize the look and feel of the browser’s scrollbar by changing some CSS properties.

CSS

Transform all text in a string to uppercase

Transform all text in a string to uppercase

Use String.toUpperCase() to transform all text in a string to uppercase.

Text Effects

Default Function Parameters

Default Function Parameters

Provide a default value to a function parameter.

Basics

Return all the elements of an array except the last one

Return all the elements of an array except the last one

Use Array.prototype.slice(0, -1) to return all but the last element of the array.

Miscellaneous

Show a loading indicator when an iframe is being loaded

Show a loading indicator when an iframe is being loaded

This post demonstrates a common case where we show a loading indicator while an iframe is being loaded.

Miscellaneous

Remove leading and trailing whitespace from a string

Remove leading and trailing whitespace from a string

Remove leading and trailing whitespace from a string.

Miscellaneous

Compress For Loops

Compress For Loops

Use the built-in forEach() method to loop through an array with one line of code.

Basics

Check if the provided value is of the specified type

Check if the provided value is of the specified type

Compare the constructor property on the value with type to check if the provided value is of the specified type.

Miscellaneous

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 14
  • Go to page 15
  • Go to page 16
  • Go to page 17
  • Go to page 18
  • 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