When more than one thread tries to access file read and write operation, we should handle the file lock system to avoid file and data corruption.

In order to avoid that complexity, we prefer to store the data in a database like MySQL, PostgreSQL, MongoDB (Client-Server) where data will be…

Nowadays most of the js interview- prescreening round have this statement validation questions to know about the candidate js fluency. If the candidate understands the basics of javascript and execution flow, they can easily clear it.

Some of the following examples might help you to understand the type of questions.

If you have feedback and suggestion feel free to give your comments.

Reach out to me at Twitter, LinkedIn.

Scope: code block

In the code block, the declared variable can be accessible within a specific block {....} , and all of its declared sub-functions. You can understand it with examples of -let, const, var.

Context: object association

this.property or this._function()

It refers to the object associated with the specific execution block to the reference of this keyword. A plain function context-this consider as Global(node) or Window(browser) object and in strict mode context-this consider as undefined.

Context and Scope

If you have feedback and suggestion feel free to give your comments.

Reach out to me at Twitter, LinkedIn.

Each method can be used for different purposes.

JS- call vs apply vs bind

call, apply, bind :

Both call and apply executes the function with the given context this and parameters.

call- When you know the exact parameter, it’s better to use call because we need to pass the parameter directly.

apply- Parameters will be passed as an array, on the execution, it will be passed according to the order.

bind it just returns a function reference, with context association of passed object and we can call the function anytime in the future with parameters.

If you have feedback and suggestion feel free to give your comments.

Reach out to me at Twitter, LinkedIn.

Hints:

Finding an element in the array (unsorted n-element) requires a time complexity of n.

Finding an element in the array (sorted n-element) using binary search requires time complexity of log n.

Problem Statement: Search in Rotated Sorted Array

We can solve the problem by splitting into two sub-problem.

  • Find the pivot element (starting element of the ascending) using the modified version of binary search. — time complexity (log n)
  • Using the pivot element, finalize the range and do a binary search over it. — time complexity (log n)

overall time complexity:

log n + log n = 2 log n — > O(log n)

If you have feedback and suggestion feel free to give your comments.

Reach out to me at Twitter, LinkedIn.

Shankar Sundaram

Full- Stack Software Consultant

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store