What are node.js bindings?

Viewed 22780

I am very new to node.js and I can not seem to find a definition anywhere as to what node.js bindings are. I have seen this term used in slides and nodejs talks but it was never clearly explained. Can anyone help clarify this concept for me? I have attached a picture of what I am referring to.enter image description here

3 Answers

Node.js bindings are series of methods that can be used in Node.js code which are in reality just running C++ code behind the scenes.

fs.readFile()  

This method is not part of javascript. It's provided to v8 as part of the node.js runtime. So javascript does not know how to read a file from disk but C++ does. So when we use javascript code and node.js to read a file from disk it just defers all of that to the C++ function that can actually read the file from disk and get the results back.

enter image description here

Javascript also has bindings in the browser too. for example;

document.querySelector()

is not a javascript code. It is implemented by chrome V8 engine.

Related