JavaScript Object-Advanced Concept- Questionnaire

 1. What is the differences of objects versus primitives? 

The fundamental difference is objects are stored and copied "by reference"  where as primitive values: strings, numbers, booleans etc  are always copied "as a whole value".

2. Is it possible to create a "real copy" in JavaScript ? 

Yes , we can use Object.assign for so called "shallow copy" . Nested object are copied by using _.cloneDeep(obj) function provided by load ash.

3. In regards to memory management in JavaScript , what happens when some thing is not needed any more? 

The main concept of memory management in JavaScript is reachability. There is a background process in the JavaScript engine that is called garbage collector. It monitors all objects and removes those that have become unreachable. Only incoming ones make an object reference.

4. Can functions be stored as  object properties in JavaScript?

Yes . The functions can be stored as properties and are called as methods.

5. What is the difference in accessing "this" in functions and arrow functions in JavaScript ?

For a function , the value of "this" is defined at run time. When a function is declared, this may use "this" , but that "this" has no value until the function is called The value of "this" during the call is object. 

6. Omitting the parenthesis for constructor with no arguments possible in JavaScript?

Yes . we can omit parenthesis after new . It isn't a good style but the syntax is permitted by specification.

7. What are constructor functions in JavaScript ?

Constructor functions or , briefly constructors are regular functions, but there's common  agreement to name them with capital letter first. These functions should only called with new .

8. Optional Chaining '?' can be possible for writing in JavaScript ?

No , this is optional chaining is used for reading and deleting but not writing.

9. What are Symbols in JavaScript?

Symbol is a primitive type for unique identifiers. These are created with Symbol() call with an optional description (name)

10 . What is the use of Symbols? 

These are used for "hidden" object properties. If we want to add a property into an object that belongs to another script or a library we can create a symbol and use it as property. Symbol are also used to alter some inbuilt behaviours of the existing JavaScript Symbols.

Comments

Popular posts from this blog

JavaScript Object-Basics - Questionnaire