---
title: "Discussion on \"Move 0's in the front and non-zeroes at the end\" | Hashnode"
description: "Discussion on \"Move 0's in the front and non-zeroes at the end\". const numbers = [1, 0, 3, 4, 0, 0, 5, true, \"js\", 2, 0, 7, 0, 9, false, 0];\n\nfunction moveAllZeroesToFront () {\n  return [...numbers.filter(item => !item && Number(item) === item), \n...numbers.filter(item => item !== 0)];\n}\n\nconst arr = moveAllZeroes..."
url: "https://hashnode.com/posts/move-0s-in-the-front-and-non-zeroes-at-the-end/6380960bc160b1d232218b1b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Move 0's in the front and non-zeroes at the end](https://harikrishna.hashnode.dev/move-0s-in-the-front-and-non-zeroes-at-the-end?utm_source=hashnode&utm_medium=feed)

const numbers = \[1, 0, 3, 4, 0, 0, 5, true, "js", 2, 0, 7, 0, 9, false, 0\]; function moveAllZeroesToFront () { return \[...numbers.filter(item => !item && Number(item) === item), ...numbers.filter(item => item !== 0)\]; } const arr = moveAllZeroes...

Nov 25, 2022 · 1 min read · harikrishna.hashnode.dev  
Read the article

-   [#move](https://hashnode.com/tag/move)
-   [#array](https://hashnode.com/tag/array)
-   [#filter-in-js](https://hashnode.com/tag/filter-in-js)
-   [#spread-operator](https://hashnode.com/tag/spread-operator)

## Written by

[Hari Krishna Anem](https://hashnode.com/@hkrishna)

@hkrishna · Hyderabad, India

  
[View profile](https://hashnode.com/@hkrishna)

Full stack developer

Full stack developer (ReactJS, NodeJS, JavaScript, PHP, SQL)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
