47) How to concatenate buffers in NodeJS?
var MyConctBuffer = Buffer.concat([myBuffer1, myBuffer2]);
buffer.copy(targetBuffer[, targetStart][, sourceStart][, sourceEnd])
- readUIntBE - It’s a generalized version of all numeric read methods, which supports up to 48 bits accuracy. Setting noAssert to “true” to skip the validation.
- writeIntBE - This will write the value to the buffer at the specified byteLength and offset and it supports upto 48 bits of accuracy.
51) Why to use “__filename” in Node.JS?
“__filename” is used to represent the filename of the code which is being executed. It used to resolve the absolute path of file. Below is the sample code for the same –
52) Why to use “SetTimeout” in Node.JS?
This is the global function and it is used to run the callback after some milliseconds.
Syntax of this method –
53) Why to use “ClearTimeout” in Node.JS?
This is the global function and it is used to stop a timer which was created during “settimeout()”.
54) Explain Web Server?
It is a software app which will handle the HTTP requests by client (eg: browser) and will return web pages to client as a response. Most of web server supports – server side scripts using scripting languages. Example of web server is Apache, which is mostly used webserver.
55) List out the layers involved in Web App Architechure?
Below are the layers used in Web Apps –
- Client - Which makes HTTP request to the server. Eg: Browsers.
- Server – This layer is used to intercept the requests from client.
- Business – It will have application server utilized by web servers for processing.
- Data – This layer will have databases mainly or any source of data.
56) Explain “Event Emitter” in Node.JS?
It is a part of Events module. When instance of EventEmitter faces any error, it will emit an 'error' event. “Event Emitters” provides multiple properties like – “emit” and “on”.
- “on” property is used for binding the function with event.
- “emit” property is used for firing an event.
57) Explain “NewListener” in Node.JS?
This event is being emitted whenever any listener is added. So when event is triggered the listener may not have been removed from listener array for the event.
58) Why to use Net.socket in Node.JS?
This object is an abstraction of a local socket or TCP. net.Socket instances implement a duplex Stream interface. These can be created by the user and used as a client (with connect() function) or they can be created by Node and can be passed to the user through the 'connection' event of a server.
59) Which events are emitted by Net.socket?
Below are the list of events emitted by Net.socket –
60) Explain “DNS module” in Node.JS?
This module is used for DNS lookup and to use underlying OS name resolution. This used to provide asynchronous network wrapper. DNS module can be imported like –
var mydns = require("dns")
61) Explain binding in domain module in Node.JS?
Below are the bindings in domain modules –
- External Binding
- Internal Binding
62) Explain RESTful Web Service?
Web services which uses REST architecture will be known as RESTful Web Services. These web services uses HTTP protocol and HTTP methods.
63) How to truncate the file in Node.JS?
Below command can be used for truncating the file –
fs.ftruncate(fd, len, callback)