Question: 1. Write a JavaScript program that declares a function but calls it before it is declared. Because of function hoisting this will work in JavaScript.

1. Write a JavaScript program that declares a function but calls it before it is declared. Because of function hoisting this will work in JavaScript. Go prove it!

Also write a function which is assigned to a variable. Call it before it is assigned and prove that this does not work.

2. The == operator compares objects by identity. But sometimes, you would prefer to compare the values of their actual properties.

Write a function, deepEqual, that takes two values and returns true only if they are the same value or are objects with the same properties whose values are also equal when compared with a recursive call to deepEqual.

To find out whether to compare two things by identity (use the === operator for that) or by looking at their properties, you can use the typeof operator. If it produces "object" for both values, you should do a deep comparison. But you have to take one silly exception into account: by a historical accident, typeof null also produces "object".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!