• 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 / Miscellaneous / Reverse the order of items in an array

Reverse the order of items in an array

Reverse the order of items in an array

Reverse the order of items in an array.

var count = [1, 2, 3, 4, 5];

// Reverse the array order
count.reverse();

// logs [5, 4, 3, 2, 1]
console.log(count);

Source

https://vanillajstoolkit.com/reference/arrays/array-reverse/

Miscellaneous

Related Snippets:

  • Count the occurrences of a value in an array
  • Cast Any Value to a Boolean
  • Find the difference between two arrays with JavaScript
  • How To Get All Unique Values and Remove Duplicates in a JavaScript Array

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2023 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers