Prompt 1
Write polyfills for built-in methods and defend the edge cases
Practice version modelled on a reported round: Public report: ServiceNow software engineer (UI) loop, 2025
What this measures
Clarify first
Confirm whether holes should be skipped like the built-in does, and whether the callback receives index and array. Confirm whether the polyfill may be attached to the prototype or must stay a standalone function.
Strong answer should cover
Validate the callback and throw the same error type the built-in throws. Iterate over own indices that exist, skip holes, and pass value, index and array to the callback with the given this value. Read the length once so elements appended during iteration are not visited. Name one edge case you chose not to cover and why, such as array-like objects.
Common miss: