Frontend Mostly Asked Interview questions and answers !
Q1: What are micro and macro task queues in JavaScript, and how do they relate to the event loop?
Answer: Micro and macro task queues are part of the event loop in JavaScript. Microtasks have higher priority and execute before macrotasks. Microtasks are typically used for high-priority, non-blocking operations like promises, while macrotasks handle less time-sensitive tasks like I/O operations and rendering updates.
Q2: How can you schedule code to run in the microtask queue, and what is the order of execution compared to the macrotask queue?
Answer: Code can be scheduled to run in the microtask queue using functions like Promise.then(), Promise.catch(), and Promise.finally(). Microtasks have higher priority and are executed before macrotasks in the event loop.
Q3: What kinds of operations are typically placed in the macrotask queue, and how do you schedule them?
Answer: Macrotasks are typically used for operations like I/O (e.g., file read), network requests (e.g., API calls), and rendering updates (e.g., modifying the DOM). You can schedule macrotasks using functions like setTimeout, setInterval, and requestAnimationFrame.
Q4: Explain the order of execution when both micro and macro tasks are in the queue.
Answer: When both micro and macro tasks are in the queue, microtasks are executed until the microtask queue is empty. Only then are macrotasks executed. This ensures that high-priority microtasks are processed first. Micro and macro task queues help manage the execution order of asynchronous operations. Microtasks allow high-priority tasks to execute promptly, maintaining UI responsiveness. Macrotasks handle less critical tasks, preventing them from blocking the main thread.
Q5: How do you schedule asynchronous code to run in the microtask queue, and what are common use cases for microtasks?
Answer: Asynchronous code can be scheduled to run in the microtask queue using Promise methods like .then(), .catch(), and .finally(). Common use cases for microtasks include handling promises, DOM mutations, and updating application state before rendering.
Q6: Can you explain the potential drawbacks of excessive use of microtasks in an application?
Answer: Excessive use of microtasks can lead to "starvation" of the macrotask queue, causing macrotasks like rendering and user input handling to be delayed. This can result in a less responsive user interface and potential performance issues.
Q1: What are micro and macro task queues in JavaScript, and how do they relate to the event loop?
Answer: Micro and macro task queues are part of the event loop in JavaScript. Microtasks have higher priority and execute before macrotasks. Microtasks are typically used for high-priority, non-blocking operations like promises, while macrotasks handle less time-sensitive tasks like I/O operations and rendering updates.
Q2: How can you schedule code to run in the microtask queue, and what is the order of execution compared to the macrotask queue?
Answer: Code can be scheduled to run in the microtask queue using functions like Promise.then(), Promise.catch(), and Promise.finally(). Microtasks have higher priority and are executed before macrotasks in the event loop.
Q3: What kinds of operations are typically placed in the macrotask queue, and how do you schedule them?
Answer: Macrotasks are typically used for operations like I/O (e.g., file read), network requests (e.g., API calls), and rendering updates (e.g., modifying the DOM). You can schedule macrotasks using functions like setTimeout, setInterval, and requestAnimationFrame.
Q4: Explain the order of execution when both micro and macro tasks are in the queue.
Answer: When both micro and macro tasks are in the queue, microtasks are executed until the microtask queue is empty. Only then are macrotasks executed. This ensures that high-priority microtasks are processed first. Micro and macro task queues help manage the execution order of asynchronous operations. Microtasks allow high-priority tasks to execute promptly, maintaining UI responsiveness. Macrotasks handle less critical tasks, preventing them from blocking the main thread.
Q5: How do you schedule asynchronous code to run in the microtask queue, and what are common use cases for microtasks?
Answer: Asynchronous code can be scheduled to run in the microtask queue using Promise methods like .then(), .catch(), and .finally(). Common use cases for microtasks include handling promises, DOM mutations, and updating application state before rendering.
Q6: Can you explain the potential drawbacks of excessive use of microtasks in an application?
Answer: Excessive use of microtasks can lead to "starvation" of the macrotask queue, causing macrotasks like rendering and user input handling to be delayed. This can result in a less responsive user interface and potential performance issues.
Forwarded from توییتر فارسی
This media is not supported in your browser
VIEW IN TELEGRAM
چطوری اون همه عدد را دید بعد چطوری حساب کتاب کرد 😳😳
•Abed•
•Abed•
This media is not supported in your browser
VIEW IN TELEGRAM
Vite in 100 Seconds
توی ۱۰۰ ثانیه کلمات کلیدیای میگه که به نظرم اگر فرصت کردید برید مطالعشون کنید. هر کدوم دنیاییه برای خودش.
#vite
توی ۱۰۰ ثانیه کلمات کلیدیای میگه که به نظرم اگر فرصت کردید برید مطالعشون کنید. هر کدوم دنیاییه برای خودش.
#vite
js_questions.pdf
7 MB
نمونه سوالات و جواب های مهم جاوااسکریپت به زبان فارسی
----
این فایل از صفحه لینکدین آقای مصطفی میری گرفته شده.
👌
#js #interview
----
این فایل از صفحه لینکدین آقای مصطفی میری گرفته شده.
👌
#js #interview
اولین دوره مقدماتی و عمیق جاوااسکریپت!
مباحث مقدماتی رو ، هم به شکل بهروزتر و هم به شکل عمیقتر بررسی میکنیم.
اطلاعات بیشتر در تصویر.
لینک کانال تلگرامی:
https://news.1rj.ru/str/alithecodeguy
مباحث مقدماتی رو ، هم به شکل بهروزتر و هم به شکل عمیقتر بررسی میکنیم.
اطلاعات بیشتر در تصویر.
لینک کانال تلگرامی:
https://news.1rj.ru/str/alithecodeguy
اگر قبلا Nextjs کار کردید و الان میخواید به نسخه جدیدش سوییچ کنید (۱۳ و بالاتر) و از ویژگیهای جدیدش استفاده کنید ، دوره زیر رو به صورت رایگان از دانلودلی میتونید دانلود کنید.
دوره خوبیه.
https://downloadly.ir/elearning/video-tutorials/introduction-to-next-js-13-v3/
#nextjs
دوره خوبیه.
https://downloadly.ir/elearning/video-tutorials/introduction-to-next-js-13-v3/
#nextjs
دانلود رایگان نرم افزار
دانلود Frontend Masters - Introduction to Next.js 13+, v3 2023-8 - دانلود رایگان نرم افزار
دانلود Frontend Masters - Introduction to Next.js 13+, v3 2023-8 - دوره آموزش آشنایی با Next.js 13، ماژول های CSS
سوال ریکتی : propagation برای همه eventها اتفاق میفته به جز یک مورد. اون چیه؟
اگر از Tailwind استفاده میکنید این ۳ تا ریسورسی که برای کامپوننتها ، آیکونها و پترنهای رایگان داخل داکیومنتش معرفی کرده رو دریابید. جذابن:
https://headlessui.dev/
https://heroicons.com/
https://heropatterns.com/
https://headlessui.dev/
https://heroicons.com/
https://heropatterns.com/
سوال مصاحبهای ریکت:
یک کامپوننت در چه شرایطی ریرندر میشه؟
جوابش ساده به نظر میاد ولی قبل از جواب دادن ، بیشتر بهش فکر کنید.
#react #interview #js @alithecodeguy
یک کامپوننت در چه شرایطی ریرندر میشه؟
جوابش ساده به نظر میاد ولی قبل از جواب دادن ، بیشتر بهش فکر کنید.
#react #interview #js @alithecodeguy