To be exact Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine.
This definition may not be clear for you ! Let me explain
1. Every browser has one or the other JavaScript Engine working behind the scenes for making everything work. This JavaScript engine is the main component of the browser as that is used to convert JavaScript code into machine code of a web page on the internet. What it actually does is it takes your JavaScript code, reads it, parses it and then compiles it into machine code to display it to you.
2. Google Chrome uses V8 JavaScript Engine, Mozilla Firefox uses Spider Monkey JavaScript engine , Microsoft Edge uses Chakra and Safari uses JavaScript Core JavaScript Engine.
Have you ever seen something different in firefox that's perfect in chrome ?
As every JavaScript engine has its own implementation and different browsers use their own JavaScript engine that is why you may face some JavaScript compatibility issues across the various browsers.
3. For easy understanding, you can say that browser is a program which uses JavaScript engine and provides a way to run JavaScript code. i.e. it provides the environment by which you can run JavaScript code. Running JavaScript is not the only task that browser performs. They have additional tasks and features as well.
4. Each language has some specification like rules and guidelines that it follows. ECMAScript is the specification for scripting languages and JavaScript also follows this specification. It has various versions like ECMAScript 2015, ECMAScript 2016..... JavaScript is one of the implementation of these specifications.
Browsers are implementing the features specified in these specifications so that we can use latest features in our JavaScript code.
5. These are the APIs provided by browsers which are "accessed using JavaScript". Here comes another JavaScript incompatibility issue we face. Each browser has its own implementation for this as well. Let me give you one example of incompatibility in DOM Manipulation API -
remove() is not supported in IE, it has removeNode() method to remove node from the DOM
Hey ! Stop I'm here to learn about nodejs right ?
Yes, we are here to understand what is NODE.JS or NODE. But for that we need to have a clear idea about What JavaScript is ? What are Browser APIs? This will make our understanding clear about Node JS.
Let's conclude -
JavaScript is a scripting language that follows ECMAScript specification. ECMAScript only specifies language features not the browser APIs. Browser APIs are implemented by the browsers which are accessed via JavaScript.
Browser APIs extends the JavaScript syntax to do certain things in the browsers. Browsers provide the environment where you can run your JavaScript and do tasks like - manipulating DOM, fetching data from server, play videos and audio etc.
0 Comments