Posts

Showing posts with the label Javascript

20 JavaScript Interview Question

Image
Hey amazing people, in this post i'll be covering many JavaScript question that Interviewer asks. So let's start.. Q1. What does the && operator do? The  &&  or Logical  AND  operator finds the first falsy expression in its operands and returns it and if it does not find any falsy expression it returns the last expression. It employs short-circuiting to prevent unnecessary work. You can use this in the catch block when closing database connection. console .log( false && 1 && []); //logs false console .log( " " && true && 5 ); //logs 5 Using if statements. const router: Router = Router(); router.get( '/endpoint' , (req: Request, res: Response) => { let conMobile: PoolConnection; try { //do some db operations } catch (e) { if (conMobile) { conMobile.release(); } } }); Using && operator. const router: Router = Router(); router.get( '/endpoin...