Blurred employer
Cover image for Meta
Logo
See All Photos

Meta

Engaged Employer

Meta

Add an Interview

Interview Question

Front End Developer Interview

-

Meta

by phone: what is a difference between Object and Array, call and apply, what is DOM structure, what is time complexity of traversing through the DOM, other very basic questions. online interview: first question is about data structure, given two arrays, one of them is a map to another, you need to traverse and exclude from array objects according to the map, in general they expect from you to build an map object from key+value but you have to use ES6 MAP where key can be stored as object and not as string or ASCII coded string. The second question was about setTimeout browser api, you will be asked to clean all timeouts, the answer is to override setTimeout and store all of them in stuck and clean them if needed.

Interview Answers

2 Answers

3

// create new TimeOut, which gives new id then clear all till that Id var newTimeOut = setTimeout[() => {}, 1); for (var i=0 ; i <= newTimeOut ; i++ ) { clearTimeout(i); }

Nikhil on

0

let timeOuts = []; const realSetTimeout = window.setTimeout; const realClearTimeout = window.clearTimeout; window.setTimeout = function (callback, time, ...args) { const id = realSetTimeout( () => { callback(); delete timeOuts[timeOuts.indexOf(id)]; }, time, ...args ); timeOuts.push(id); return id; }; window.clearTimeout = function (id) { realClearTimeout(id); delete timeOuts[timeOuts.indexOf(id)]; }; function clearAllTimeout() { timeOuts.forEach((id) => realClearTimeout(id)); timeOuts = []; }

Implementation for clearAllTimeout on

Add Answers or Comments

To comment on this, Sign In or Sign Up.

Meta Careers

Cover image for Meta

Bring the world closer together with Meta Meta builds technologies that help people connect, find communities and grow businesses. When...More

  • Our Technologies
  • The Metaverse
  • Meta and You
This is the employer's chance to tell you why you should work for them. The information provided is from their perspective.