• 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 largest integer less than or equal to a number

Return the largest integer less than or equal to a number

Returns the largest integer (whole number) less than or equal to a number.

Math Related

Detect the preferred language of the current user

Detect the preferred language of the current user

Use Navigator.language or the first value of Navigator.languages if available, otherwise return defaultLang.

User Details

Get the absolute value of a number with JavaScript

Get the absolute value of a number

Get the absolute (positive) value of a number.

Math Related

Return the scroll position of the current page

Return the scroll position of the current page

Use Window.pageXOffset and Window.pageYOffset if they are defined, otherwise Element.scrollLeft and Element.scrollTop.

Navigation

Zoom an image

Zoom an image

How to create an image zoomer which allows users to zoom an image using a range slider.

Image Effects

Format a number to a fixed number of decimal places

Format a number to a fixed number of decimal places

Format a number to a fixed number of decimal places. Pass in the number of decimal places as an argument

Math Related

Retrieve the value of a CSS rule for the specified element

Retrieve the value of a CSS rule for the specified element

Use Window.getComputedStyle() to get the value of the CSS rule for the specified element.

CSS

Scroll to an element smoothly (smooth scroll)

Scroll to an element smoothly (smooth scroll)

We can scroll to given element smoothly (smooth scroll) by passing behavior: ‘smooth’.

Navigation

Convert a string to a number

Convert a string to a number

Sometimes it returns integer. Other times it returns a float. And if you pass in a string with random text in it, you’ll get NaN, an acronym for Not a Number.

Miscellaneous

Check if array has duplicates

Check if array has duplicates

Checks if there are duplicate values in a flat array. Use Set to get the unique values in the array.

Miscellaneous

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