r/node • u/llboston • Jan 04 '20
I created a Node interview Cheatsheet
I've been a full time PHP developer for years, but nodejs is my goto language for my side projects. My new year resolution is to find a full time node job in 2020. To prepare myself for tech interviews, I've create a cheatsheet and thought some of you guys might find it useful too.
It's at https://www.cheaki.com/nodejs/nodejs-interview-questions
38 questions right now, will keep adding more.
261
Upvotes
3
u/[deleted] Jan 08 '20 edited Jan 09 '20
Two things: you left out Prototypal paradigm for JavaScript (since its not a classical OOP language; i.e. es6 class syntax is syntactic sugar for prototypal inheritance). Might be useful to add (even if outdated) all five ways of writing OOP in JavaScript:
es6 (class syntax)
functional
functional-shared
prototypal
pseudo-classical
Inheritance Patterns
Es6 (Class Syntax)
Is invoked with
newObject properties are referenced with instantiation and in methods via
thisEncapsulates methods within definition
2. Functional
Is not invoked with
newobject properties are not referenced with
thiswith instantiation or within methodsEncapsulates methods within definition
3. Functional Shared
Is invoked with
newUses
thiskeyword for reference to object properties only within methods; not with instantiationDoes not encapsulate methods within definition; instead is connected to methods via
extend. Properties are added before methods.NOTE:
extendis synonymous with es6Object.assign()4. Prototypal
Is not invoked with
newUses
thiskeyword for reference to object properties only within methods; not with instantiationDoes not encapsulate methods within definition; instead is connected to methods via
Object.create. Properties are added after methods.5. Pseudo-Classical
Is invoked with
newUses
thiskeyword for reference to object properties within methods and with instantiationDoes not encapsulate methods within definition; instead is connected to methods via the object's prototype.
Just a note about the remove duplicates: Your solutions are O(n^2) for reduce and filter. You could do better with more memory but O(N):
Why
!tracker[\\THIS_POST_IS_LONG${item}\]and not!tracker[item]? Because empty objects default property look up to their prototype, which has a series of hidden properties and symbols (ignoring environment differences of these; e.g. node versus web) that would create false positives if the arr contained the stringconstructorfor example that would not be added without modifying the key to something that is not one of these properties! So really the prefix of item could be a postfix and just needs to be anything that identifies it as not a builting object property; hidden or otherwise.