Skip to content

Instantly share code, notes, and snippets.

@talentedandrew
Forked from azemetre/f6k.md
Created January 7, 2022 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talentedandrew/6c08fb9fedaaa04f2cbf3fa2ef170434 to your computer and use it in GitHub Desktop.
Save talentedandrew/6c08fb9fedaaa04f2cbf3fa2ef170434 to your computer and use it in GitHub Desktop.
for your consideration

Explain Promises like I'm five years old

What does it mean when it is said that JS has first-class functions?

Explain higher order functions?

Explain this

Q: What are the advantages of using ES6 maps over objects? What about using ES6 sets over arrays? A: Maps and Sets have easier ways of checking if an item exists with in them. They also have properties that make it easier to delete an item.

Q: Write an array flatten function


/ could be potentially more than 3 keys in the object above
items = [
 {color: 'red', type: 'tv', age: 18},
 {color: 'silver', type: 'phone', age: 20},
 ...
];

excludes = [
 {k: 'color', v: 'silver'},
 {k: 'type', v: 'tv'},
 ....
];

function excludeItems(items, excludes) {
  excludes.forEach(pair => {
     items = items.filter(item => item[pair.k] === item[pair.v]);
  });
  return items;
}
  1. Describe what this function is doing
  2. What is wrong with that function?
  3. How would you optimize it?

Write an emitter class:

emitter = new Emitter();

// 1. Support subscribing to events.
sub = emitter.subscribe('event_name', callback);
sub2 = emitter.subscribe('event_name', callback2);

// 2. Support emitting events.
// This particular example should lead to the `callback` above being invoked with `foo` and `bar` as parameters.
emitter.emit('event_name', foo, bar);

// 3. Support unsubscribing existing subscriptions by releasing them.
sub.release(); // `sub` is the reference returned by `subscribe` above


Given two identical DOM tree structures, A and B, and a node from A, find the corresponding node in B.

implement a simple Observable.

Flatten array. This array can have multiple types: {}, [], "", undefined, null, 123 are all valid types inside the array

Basic JS questions about closure, map funciton, forEach function, apply function, call function, DOM tree, difference between array and object.

Javascript DOM tree manipulation

Given a node from a DOM tree find the node in the same position from an identical DOM tree.

Given two identical DOM trees (not the same one), and a node from one of them find the node in the other one.

Basic JavaScript async stuff (you should know event bubbling, debounce (its variant)... know how to code it). It would be a good idea to be aware of JS closure as well. https://gist.github.com/simplesthing/e269d5cfbbd156cca78b

Given a picture, how would you hide/show a child picture on hovering on this parent?
https://www.glassdoor.com/Interview/Given-a-picture-how-would-you-hide-show-a-child-picture-on-hovering-on-this-parent-QTN_1502329.htm

if you have 500 revisions of a program, write a program that will find and return the FIRST bad revision given a isBad(revision i) function. https://www.glassdoor.com/Interview/If-you-have-500-revisions-of-a-program-write-a-program-that-will-find-and-return-the-FIRST-bad-revision-given-a-isBad-revi-QTN_1255475.htm

Given an input array and another array that describes a new index for each element, mutate the input array so that each element ends up in their new index. Discuss the runtime of the algorithm and how you can be sure there won't be any infinite loops. https://www.glassdoor.com/Interview/Given-an-input-array-and-another-array-that-describes-a-new-index-for-each-element-mutate-the-input-array-so-that-each-ele-QTN_446534.htm

what is 'this' keyword and what's its behavior

Implement a simple store class with set(Node, value ), get(Node) and has(Node) methods, which store a given Nodes with corresponding values

https://www.glassdoor.com/Interview/Implement-a-simple-store-class-with-set-Node-value-get-Node-and-has-Node-methods-which-store-a-given-Nodes-with-corre-QTN_2435822.htm


You are given an array of N elements in the form "property1: value1; property2: value2;...;propertyX: valueX;" for some some N and any X. There is also another array of M elements of the form "property: value". You are supposed to write an algorithm to remove every element in the N length array that has a "property: value" pair in the M length array.

The trick is that the most intuitive solution of iterating through the M array and filtering the N array at each element is already written. You must come up with a solution that solves the problem in less than O(NM) time.

https://www.glassdoor.com/Interview/You-are-given-an-array-of-N-elements-in-the-form-property1-value1-property2-value2-propertyX-valueX-for-some-som-QTN_2855045.htm

How many times would addEventListener('scroll', handleScroll); run as the user looks at their News Feed? And what would be user experience if the handleScroll function takes 100ms to execute.

how could you implement debouncing? Say you wanted the handleScroll function to be called only after 200ms has passed between scroll events.


Q: Using HTML and CSS, show how you would create an image that would display another image (aligned to the bottom, right) when the user hovers over the image. https://www.glassdoor.com/Interview/1-In-JavaScript-write-a-function-that-takes-an-array-as-input-that-can-contain-both-ints-and-more-arrays-which-can-also-QTN_610285.htm

ex. The Facebook "edit profile picture" icon

A:

.profile-pic {
  display: block;
  width: 200px;
  height: 200px;
  background: url(http://lorempixel.com/200/200) no-repeat;
  position: relative;
}

.edit-link {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 100px;
  height: 50px;
  background: url(http://lorempixel.com/100/50) no-repeat;
  display: none;
}

.profile-pic:hover .edit-link {
  display: block;
}

A:

CSS question is fairly easy. Given two img elements with the classes "one" and "two", you can give them the styles:
.two{
    display:none;
}
.one:hover + .two{
    display: block;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment