• 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
Home / Archives for Miscellaneous

Miscellaneous

Capitalize the first letter of a string

Capitalize the first letter of a string

This snippet capitalizes the first letter of a string.

Miscellaneous

Redirect to a specified URL

Redirect to a specified URL

Use Window.location.href or Window.location.replace() to redirect to url. Pass a second argument to simulate a link click (true – default) or an HTTP redirect (false).

Miscellaneous

Get an attribute on an element

Get an attribute on an element

Use Element.getAttribute() to get an attribute (including data attributes) on an element.

Miscellaneous

Optional Chaining to Prevent Crashes

Optional Chaining to Prevent Crashes

If you access an undefined property, an error is produced. This is where optional chaining comes to the rescue.

Miscellaneous

Return all elements in an array except for the first one

Return all elements in an array except for the first one

Return Array.prototype.slice(1) if Array.prototype.length is more than 1, otherwise, return the whole array.

Miscellaneous

Highlight an element when dragging a file over it

Highlight an element when dragging a file over it

We will highlight the element when user drags a file over it. For example, the element will have a dashed border which can be simulated by a CSS class.

Miscellaneous

Remove Duplicates From an Array

Remove Duplicates From an Array

In JavaScript, Set is a collection that lets you store only unique values. This means any duplicated values are removed.

Miscellaneous

How to loop through arrays and array-like objects in JavaScript

Loop through arrays and array-like objects

Here is how to loop through arrays and array-like objects using JavaScript.

Miscellaneous

How to Get the Query String in JavaScript

How to Get the Query String in JavaScript

When you’re working with JavaScript, sometimes you need to access query string parameters in your script.

Miscellaneous

Check if an Object Is Empty

Check if an Object Is Empty

ere are some different methods that you could use to check if an object is empty in modern browsers that support the ES5 edition of JavaScript.

Miscellaneous

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 10
  • Go to page 11
  • Go to page 12
  • Go to page 13
  • Go to page 14
  • Interim pages omitted …
  • Go to page 16
  • 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