• 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

Unix timestamp from date

Unix timestamp from date

Gets the Unix timestamp from a Date object. Use Date.prototype.getTime() to get the timestamp in milliseconds and divide by 1000 to get the timestamp in seconds. Use Math.floor() to appropriately round the resulting timestamp to an integer. Omit the argument, date, to use the current date. Source https://www.30secondsofcode.org/js/s/get-timestamp

Time & Date

Preventing paste into an input field

Preventing paste into an input field

See the codepen: https://codepen.io/JSsnippets/pen/qBbyMoJ Source https://github.com/roeib/JavaScript-snippets#preventing-paste-into-an-input-field

Forms

Get and set the text of an element (without markup)

Get and set the text of an element (without markup)

Get and set the text of an element without its markup. Source https://vanillajstoolkit.com/reference/html/textcontent/

Miscellaneous

Range generator

Range generator

Creates a generator, that generates all values in the given range using the given step. Use a while loop to iterate from start to end, using yield to return each value and then incrementing by step. Omit the third argument, step, to use a default value of 1. Source https://www.30secondsofcode.org/js/s/range-generator

Generators

Notify when element size is changed

Notify when element size is changed

Source https://github.com/roeib/JavaScript-snippets#notify-when-element-size-is-changed

Page Details

Get and set HTML content for an element

Get and set HTML content for an element

Note: using innerHTML with third-party or user-submitted content can expose you to cross-site scripting (XSS) attacks. Source https://vanillajstoolkit.com/reference/html/innerhtml/

Miscellaneous

Check if a node is in the viewport

Check if a node is in the viewport

Source https://github.com/roeib/JavaScript-snippets#check-if-a-node-is-in-the-viewport

Page Details

Remove an item from an object

Remove an item from an object

Use the delete operator on the key to remove. Source https://vanillajstoolkit.com/reference/objects/delete/

Miscellaneous

Return an array of elements that appear in both arrays

Return an array of elements that appear in both arrays

Use Array.prototype.includes() to determine values that are not part of values. Use Array.prototype.filter() to remove them. Source https://www.30secondsofcode.org/js/s/similarity

Miscellaneous

Check if a string is a valid JSON

Check if a string is a valid JSON

This is useful for making sure that the JSON is valid before you perform another operation on it. You can learn more about how to use json parse on WebReference. While working, this json formatter and validator is a handy tool. Source https://github.com/roeib/JavaScript-snippets#check-if-a-string-is-a-valid-json

Miscellaneous

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 6
  • Go to page 7
  • Go to page 8
  • Go to page 9
  • Go to page 10
  • 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