Top 10 Javascript basic interview questions and answers[PART II]

Ms Chi
5 min readSep 10, 2022

Click here for PART I. More questions are related to array utility method, object, keyword(new, constructor, prototype), Object.freeze(), deep/shallow copy, scope, closure and hoisting. The techinical interview is always not SIMPLE, however the more we practice, the more confident we feel!

11. What is the difference of Deep/Shallow copy of non-primitive data type such array and object?

Shallow copy means the ONLY old reference of nested obj/array is copied. However deep copy is storing all values and addressed to a new reference, so that it will not modify the original copy. Lodash is one of the popular library for deep copy.

12. How does Object.freeze() work with nested object value?

Object.freeze() is used to assign the object values to have READ-ONLY property, however it only applies to non-nested object value. In order to avoid nested object value modification/mutation, recursive function can do the trick. It can be a RED FLAG if candidate does not mention that Object.freeze() only applies for non-nested object value.

--

--

Ms Chi
Ms Chi

Written by Ms Chi

A typescript JS people who breathes React and Node. Long term learning curve is a must to keep us fresh and competitive. Don’t be overwhelmed by the speed.