---
title: "Comment by V K on \"Heaps in JavaScript\" | Hashnode"
description: "percolateDown function is exactly same as heappop. This won&#39;t create a heap of out an array. If the initial array is [3,5,4,10,2,1]. After percolateDown&#39"
url: "https://hashnode.com/posts/heaps-in-javascript/617fef0ff597ba4a82795f31/comment/651ef0f37e37d3b346c61f0e"
---

[Discussion](https://hashnode.com/posts/heaps-in-javascript/617fef0ff597ba4a82795f31)

Comment [Heaps in JavaScript](https://hashnode.com/posts/heaps-in-javascript/617fef0ff597ba4a82795f31)

[V K](https://hashnode.com/@doncorleone)

[Oct 5, 2023](https://hashnode.com/posts/heaps-in-javascript/617fef0ff597ba4a82795f31/comment/651ef0f37e37d3b346c61f0e)

percolateDown function is exactly same as heappop. This won't create a heap of out an array. If the initial array is \[3,5,4,10,2,1\]. After percolateDown's execution array will be \[3,2,1,10,5,4\] which is still not a heap. Edit: for some one looking at it in future. In heapify function, instead of running from first node to last. It should run from last to first so (let i = last;i>=0;i--)

[Krzysztof Witkowski](https://hashnode.com/@kriskw1999)

[Jul 14, 2024](https://hashnode.com/posts/heaps-in-javascript/617fef0ff597ba4a82795f31/comment/651ef0f37e37d3b346c61f0e#reply-669387ee651e88d1ba647e51)

I was wondering exactly the same thing reading this function. Thanks for confirming my doubts!
