docsearch: TypeError: newCollection[key].push is not a function

Do you want to request a feature or report a bug?

What is the current behavior?

If the current behavior is a bug, please provide all the steps to reproduce and a minimal JSFiddle example or a repository on GitHub that we can npm install and npm start.

What is the expected behavior?

https://eggjs.org/zh-cn/tutorials/index.html

untitled

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (16 by maintainers)

Most upvoted comments

wow, I love your neat solution, it is better than mine.

But according to the hasOwnProperty MDN, we might avoid directly to call newCollection’s hasOwnProperty.

How about this ?

!({}).hasOwnProperty.call(newCollection, key)

Or

!Object.prototype.hasOwnProperty.call(newCollection, key)

But I think your solution is better, because newCollection won’t change the original hasOwnProperty, and the code is shorter.

I am very glad to submit a PR.

More Information #7853