Questions d'entretien

Entretien pour Senior UI Developer

-Hyderâbâd

ValueLabs

You have two methods: one method takes long time to run and the other completes in short time. You execute the long method first and after that you execute the short method. Which one will complete first. There is no setTimeout involved.

Répondre

Réponses aux questions d'entretien

4 réponse(s)

0

My answer: The long method finishes first and then short method executes and completes. Expected answer: The short method returns first!

Utilisateur anonyme le

0

the short method returns first! is the right answer since two methods will run parallel. As javascript is async events handling. You may right if had quested him is the methods run in sequence.

Utilisateur anonyme le

0

@Anonymous. It looks like you have not read the question well. It says that there is no setTimeout[) involved. If you have read the question, I have some questions for the answer that you provided. 1. Is asynchronous same as multithreading? I remember reading that JavaScript is single-threaded. 2. Suppose the short method depends on some value modified by the long method. As you said, lets suppose that the short method returns first even though it is next to the long method in sequence. In this case, how do you manage your program?

Utilisateur anonyme le

0

I think the question is quite vague. It depends on how the functions are executing. If the functions are executing one by one in a sequence, then, of course, the long function will take its time to complete then the short function will start execution.

Aakash Arora le

Ajouter des réponses ou des commentaires

Pour commenter ceci, connectez-vous ou inscrivez-vous.