Node.js

  1. How to enable v8 inspector for debugging and profiling?
    • –inspect
    • –inspect=<PORT NO>
  2. NodeJS is advised to be used for?
    • Single Page Applications
    • JSON APIs based Applications
    • Data steaming applications
    • Data Intensive Realtime Applications
    • I/O bound applications
  3. NodeJS is not advised to be used for?
    • CPU intensive applications
  4. What’s the code to print the name of Operating system?
    • log(“type:” + os.type());
  5. What does REST stands for?
    • Representational State Transfer
  6. Ways to create a child process in Nodejs?
    • spawn()
    • fork()
    • exec()
    • execFile()
  7. How to print current directory in Nodejs?
    • log(‘Current directory’ + process.cwd());
  8. Which is package manager for Node?
    • NPM
  9. Which framework includes input validation?
    • Koa
  10. In Express application you handles the route ‘/user/:name’. How to access the property name?
    • params.name
  11. For Linux, which environment variable is needed to set for successful NodeJS installation?
    • Export PATH=$PATH:/usr/local/nodejs/bin
  12. Which file extensions supports Node module system?
    • .js
    • .node
    • .json
  13. What will be the output of following code in console?

const EventEmitter = require(‘events’);
const myEve = new EventEmitter();
myEve.on(‘try’, () => {});
myEve.on(‘catch’, () => {});
const sym = Symbol(‘type’);
myEve.on(sym, () => {});

console.log(myEve.eventNames());

  • Prints: [ ‘try’, ‘catch’, Symbol(type) ]
  1. Correct way to import http module?
    • require(‘http’);
  2. If we have following construction in Express.js, which paths will match this route?
    get(‘/ak+hm’, function (req, res) {

res.send(‘ak+hm’)

})

  • akhm, akkhm, akkkhm, and so on
  1. Which of the commands exit from REPL?
    • double ctrl + c
    • ctrl + d
  2. Which method is used to check modifications in files?
    • Watch
  3. True statements about the fs module of Node?
    • Asynchronous methods of fs module take last parameter as completion function callback
    • Every method in fs module have synchronous as well as asynchronous form.
  4. How to convert from Buffer instance to string of base64?
    • toString(“base64”);
  5. Which variables can be used in modules?
    • __filename
    • __dirname
  6. Which engine built of NodeJs framework/platform?
    • Google Chrome’s JavaScript V8 Engine
  7. Which utility modules are available in NodeJS?
    • OS
    • Path
    • Net
    • DNS
    • Domain
  8. Which method will print to the console without a trailing new line?
    • stdout.print()
  9. Which is most popular NodeJs framework?
    • Express
  10. Which of the following is the result of module.id?
    • File name
  11. Which method can be used to write a file in Node.js?
    • createWriteStream()
  12. Which method of fs module is used to truncate a file?
    • unlink(path, callback)
  13. Which are the debug commands to debug node server?
    • node debug <test.js>
    • node debug – p <pid>
    • node debug <URI>
  14. Which console commands will update all installed global packages to the latest available versions?
    • npm update –g
  15. How to access the environment variable, «ENV_VARIABLE» in Node.js?
    • env.ENV_VARIABLE
  16. Which method can be used to read the contents of a directory?
    • readdir()

Leave a Reply

Your email address will not be published. Required fields are marked *