Issue #3006Opened September 7, 2020by ashercoren0 reactions

BUG: Don't loop over objects with a for in loop

Question

Version: 0.16.22

Are you able to reproduce the bug from the demo?

[-] Yes [ ] No

What is the expected behavior? Looping over objects should be done using Object.keys.forEach..., and not with a for-in loop.

Looping over objects with a for in loop will include properties that are inherited through the prototype chain. This behavior can lead to unexpected items in your for loop. More details can be found here.

Are you able to attach screenshots, screencasts or a live demo?

[ ] Yes (attach) [-] No

Answers (1)

ashercorenSeptember 7, 20200 reactions

This caused a bug in our application since we are using some package that adds properties to the object prototype. When trying to initialize a grapes.js editor we get an error in the console.

image

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.