• 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

Add an element to the DOM

The original way to add elements to the DOM. Call it on the parent of the element you’re inserting your new element before (the referenceNode), and pass in both the new element and the reference node as arguments. You can also use it to inject an element after another one by using the .nextSibling property on your referenceNode. Source https://vanillajstoolkit.com/reference/dom-injection/element-insertbefore/

Miscellaneous

Remove falsy values from an array

Remove falsy values from an array

Removes falsy values from an array. Use Array.prototype.filter() to filter out falsy values (false, null, 0, “”, undefined, and NaN). Source https://www.30secondsofcode.org/js/s/compact

Miscellaneous

How to change the value of an object which is inside an array

How to change the value of an object which is inside an array

Source https://github.com/roeib/JavaScript-snippets#how-to-change-the-value-of-an-object-which-is-inside-an-array

Miscellaneous

Create an element

Create an element

Source https://vanillajstoolkit.com/reference/dom-injection/createelement/

Miscellaneous

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

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

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

Perform a shallow merge of two or more objects

Perform a shallow merge of two or more objects

Perform a shallow merge of two or more objects into the first. Pass in each object to merge as an argument. Note: in a shallow merge, nested objects are overwritten completely rather than having their values merged together. All objects are merged into the first. To create a new object, pass in an empty object as […]

Miscellaneous

  • « Go to Previous Page
  • Go to page 1
  • Interim pages omitted …
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Go to page 6
  • Go to page 7
  • 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