Showing posts from September, 2021

Node.js interview questions set 2

  Let start with set 2, 5)What is buffer in node.js? Ans:  Node.js includes an additional data type called Buffer (not available in browser's JavaScript).  Buffer is mainly used to store binary data while reading from a file or receiving packets over the network. Buffer class is a global class that can be accessed in an application without importing the buffer module. Ex:var buf = new Buffer(10); 6)Explain the concept of URL module in Node.js? Ans: The URL module in Node.js splits up a web address into readable parts.  Use require() to include the module: var url = require( 'url' ); Then parse an address with the url . parse() method, and it will return a URL object with each part of the address as properties . var url = require( 'url' ); var adr = 'http://localhost:8080/default.htm?year=2021&month=september' ; var q = url . parse(adr, true); console . log(q . host); // returns 'localhost:8080' console . log(q . pathname); // retur