DEV Community

Discussion on: JS Polyfills asked in Interviews

Collapse
 
abhishekraj272 profile image
Abhishek Raj

I have written partial polyfill, which shows how it works. I have not tried to replicate whole code of flat method.

Also you can observe I have written it as pure function not as Array method.

Collapse
 
marzelin profile image
Marc Ziel

Partial polyfill, huh? Oh I see, It's not a bug it's a feature ;) Good luck with this attitude.

Thread Thread
 
abhishekraj272 profile image
Abhishek Raj
Thread Thread
 
marzelin profile image
Marc Ziel

I can understand when someone skips some edge cases when writing an example because supporting them would make code really long or much harder to understand. But this isn't the case here. You could write () => [] and argue all day that this is a partial polyfill of flat because it works for some inputs. Or you could fix your buggy code.