Understading working of javascript : Google’s JavaScript V8 Engine

What is javascript? Javascript is a single threaded,aynchrounous,non-blocking concurrent language.If you have an javascript code ,it is run by engines.Javascript v8 Engine powers Node.js ,Chrome browser,Electron(Desktop Application dev).There are many Javascript engines like Chakra(Microsoft), Spidermonkey(Firefox). We focus on V8 Javascript engine to understand more about JavaScript engines here.What V8 basically does is that it generate machine code from source code . All modern JavaScript engines use Just In Time(JIT) compilation also V8. V8 does’nt generate machine code Ahead of time but on run time when we need it.Compilation and execution goes at the same time. V8 features an interpreter called Ignition and an optimizing compiler  called TurboFan. Bookmark this page . Detailed study on V8 Engine will be available here soon…..  

Javascript try,catch and finally : Error handling
interview questions , Javascript / June 21, 2018

When we run Javascript code unexpected errors can happen but how to handle these errors… Handling the errors are necessary for providing a better end user experience and Javascript provides some features to efficiently handles the errors Try statement – Try statement checks for errors in a block of code. Consider the following code,the httpGet function send a Get request to a dummy api

This successfully runs , but what if we provide a wrong api url

  As you can see try and Catch Statement lets us handle errors while the code is being executed Throw Statement Throw statement lets us throw custom errors.The error thrown can be a string,number or an object Consider the following example

Here the request was successful but we expected a.userId to be 100.Since the result was not the expected one we throw a custom error.  ‘Not Expected Result’; Using the try and catch statements together, we can control the  program flow and generate custom error messages. Finally statement Finally statement ,lets us execute a block of code irrespecitve of the results of the try and catch.Consider the above example in which we throws a custom error.Now we add a finally…

Share this page in social media platforms