DEV Community

Dezina
Dezina

Posted on

Javascript interview preparations

There are thousands of self-taught JavaScript programmers looking for web development positions. Unfortunately, self-learning or training classes, often leaves gaps in people’s understanding of the language itself. The problem is that questions testing your understanding of JS are exactly what many tech companies ask in their interviews. Some many know to do coding, but lack a solid grasp of the language. Just writing the some important concepts of js.

Shallow clone(copy) & deep clone(copy)

Shallow copy
copy the original object into the clone object then the clone object has the copy of the memory address of the original object. Means both points to the same memory address. A shallow copy means once we make changes in the clone object it will be reflected back to the original object as well.
_code:_
var obj1 = {
    id: 1,
    company: "GFG"
};
var obj2 = obj1;
obj2.id = 2;
console.log(obj1.id);
console.log(obj2.id);
_output:_
2
2

Deep copy
But in the case of deep copy, changing the value of the cloned object will not reflect into the original object, because the original object has its own reference object and after cloning, the cloned object has its own referenced object. Both are different.
_code:_
var student1 ={ 
    name : "Manish",
    company : "Gfg"

    }
    var student2 =  { ...student1 } ;
    student1.name = "Rakesh"
    console.log("student 1 name is",student1.name)
    console.log("student 2 name is ",student2.name);
_output_
student 1 name is Rakesh
student 2 name is  Manish
Enter fullscreen mode Exit fullscreen mode

Events

Browser events
Js events
Enter fullscreen mode Exit fullscreen mode

Value vs. Reference
Scope
Hoisting
Closures
this
new
apply, call, bind
Prototypes & Inheritance
Asynchronous JS
Higher Order Functions

Top comments (0)