KEY NOT FOUND: coverImgAlt
Logo
See All Photos
Best Places to Work 2022

Meta

Engaged Employer

Meta

Add an Interview

Interview Question

Front End Developer Interview

-Tel Aviv-Yafo

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.

AnswerAdd Tags

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

Meta builds technologies that help people connect, find communities, and grow businesses. When Facebook launched in 2004, it changed the...More

  • Our Mission
  • Diversity & Inclusion
  • Meta Careers
  • Our Principles
This is the employer's chance to tell you why you should work for them. The information provided is from their perspective.