• 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

Bitwise Operators in JavaScript

Bitwise Operators in JavaScript

JavaScript provides several bitwise operators that allow you to manipulate the individual bits within a value. These operators include: Here’s a brief explanation of each operator and an example of how to use it: Bitwise AND (&) The bitwise AND operator compares each bit of the first operand to the corresponding bit of the second […]

Basics

Assignment Operators in JavaScript

Assignment Operators in JavaScript

JavaScript has several assignment operators that can be used to assign values to variables. These operators are as follows: The “=” operator: This is the most basic assignment operator and is used to assign a value to a variable. For example: The “+=” operator: This operator is used to add the value on the right […]

Basics

The JavaScript function Math.pow()

The JavaScript function Math.pow()

The Math.pow() function in JavaScript is used to raise a number (called the base) to a certain power (called the exponent). The syntax for using this function is Math.pow(base, exponent). For example, to raise 2 to the power of 3, you would use the following code: In this example, 2 is the base and 3 […]

Basics, Math Related

The JavaScript function Math.floor()

The JavaScript function Math.floor()

The JavaScript function Math.floor() is used to round a number down to the nearest integer. This function takes a single argument, which is the number that you want to round down. For example, if you wanted to round the number 4.7 down to the nearest integer, you would use the following code: As you can […]

Basics, Math Related

The JavaScript function Math.abs()

The JavaScript function Math.abs()

The JavaScript function Math.abs() is a built-in function that returns the absolute value of a number. The absolute value of a number is its distance from zero, regardless of whether the number is positive or negative. Here is an example of how to use the Math.abs() function: In the above example, num1 is assigned the […]

Basics, Math Related

Arithmetic Operators in JavaScript

Arithmetic Operators in JavaScript

JavaScript has several arithmetic operators that are used to perform mathematical operations on numbers. These operators include: Addition (+): This operator is used to add two or more numbers together. Subtraction (-): This operator is used to subtract one number from another. Multiplication (*): This operator is used to multiply two or more numbers together. […]

Math Related, Basics

Viewport Width

Viewport Width

There are two methods to get the viewport width: window.innerWidth and document.documentElement.clientWidth. The former is more accurate. The latter has better browser support. To get the best of both worlds, try innerWidth first, and fallback to clientWidth if not supported. Source https://vanillajstoolkit.com/reference/viewport/viewport-width/

Page Details

Using the spread operator

Using the spread operator

The spread operator allows you to quite literally “spread” out an array. This can be used to transform an array into a list of arguments or even combine two arrays together. You could also use it to form a list of arguments to a function too. Check it out: In the first example we show […]

Miscellaneous

Drop list elements from the left

Drop list elements from the left

Creates a new array with n elements removed from the left. Source https://www.30secondsofcode.org/js/s/drop

Miscellaneous

Get the height of the viewport

Get the height of the viewport

There are two methods to get the viewport height: window.innerHeight and document.documentElement.clientHeight. The former is more accurate. The latter has better browser support. To get the best of both worlds, try innerHeight first, and fallback to clientHeight if not supported. Source https://vanillajstoolkit.com/reference/viewport/viewport-height/

Page Details

  • « 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 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