Question

In: Computer Science

1 What is Node js and In which Language Node Js is written?

use any online document and ppt provided to answer the following question

  1. -What is Node js and In which Language Node Js is written?
  2. -Explain CLI in Node.js and provide on command to install locally or globally?
  3. -Explain Modules in Node Js and provide an example you would use for an API ?
  4. -What are CommonJs Modules describe the most important ones ?
  5. -For what require() is used in Node Js ?
  6. -Explain What is a Javascript Engine, what is javascript framework , and what is ECMAScript?
  7. -write a command to get a node js installed in your machine and how you upgrade or downgrade from the current version ?
  8. -Explain What is NPM and when do you use is. provide an example illustrating use of NPM?
  9. -How to stop master process without suspending all of its child processes?
  10. -What does emitter do and what is dispatcher. write example for each ?
  11. -Difference between cluster and child_process modules?

Solutions

Expert Solution

1. What is Node js and In which Language Node Js is written?

  • Node.js is an open source run time environment to run javascript code on server side.
    • Node.js is primarily used for developing several real time web applications such as chat applications, multi-player gaming, data streaming.
  • Node.js is written in C, C++ and Javascript. It uses Google’s open source V8 Javascript Engine to convert Javascript code to C++

2. Explain CLI in Node.js and provide a command to install locally or globally?

  • Command Line Interface (CLI) is a text based interface between the user and program to execute several commands on the program.
    • Node.js comes with a variety of CLI options. These options expose built-in debugging, multiple ways to execute scripts, and other helpful runtime options.
  • Command to install packages loacally...
    • npm install
  • Command to install packages globally...
    • npm install -g

3. Explain Modules in Node Js and provide an example you would use for an API?

  • Modules in Node.js is a set of libraby functions written in javascript which allow the user to solve a lot of coding problems.
  • request is the name of one of the modules available in Node.js to use API. This module is used to make HTTP requests from Node.js program.

4. What are Common Js Modules describe the most important ones ?

  • List of common Node.js modules...
    • gm.js : Used to graphical image manipulation such as resizing, clipping, encoding.
    • express.js : It is designed for building web applications and APIs
    • gulp.js : Helps in automate and enhance the node js application work flow.
    • Moment.js : A Date object module for working with dates and times
    • joi.js : Module for data validation. It can validate any kind of data from simple scalar data types such as strings, numbers or booleans, to complex values consisting of several levels of nested objects and arrays

5. For what require() is used in Node Js ?

  • The basic functionality of require() function is that it reads a JavaScript file, executes the file, and then proceeds to return the exports objects.
  • require() function is used to import modules in Node.js

6. Explain What is a Javascript Engine, what is javascript framework , and what is ECMAScript

  • Javascript Engine:
    • A JavaScript engine is a program or an interpreter which executes JavaScript code. A JavaScript engine can be implemented as a standard interpreter, or just-in-time compiler that compiles JavaScript to bytecode in some form.
  • Javascript framework:
    • JS frameworks are collections of JavaScript code libraries that provide developers with pre-written Javascript code to use for routine programming features and tasks, literally a framework to build websites or web applications around.
  • ECMAScript:
    • ECMAScript (European Computer Manufacturers Association Script) is a Standard for scripting languages such as JavaScript.
    • ECMAScript is widely used on the World Wide Web especially for client-side scripting.

7. write a command to get a node js installed in your machine and how you upgrade or downgrade from the current version ?

  • command to get a node js installed in your machine..
    • node -v [The letter -v in the command prints the version of Node.js installed in your system]
  • Command to upgrade Node.js from the current version...
    • sudo npm install -g n

    • sudo n stable [to install latest stable version of node.js]

  • Command to downgrade Node.js from the current version...

    • node -v [prints the current version of node.js]

    • nvm install  [install the version of node.js that is required, the version should be older than the current one installed]
    • nvm use [use the newly installed version of node.js(a downgraded node.js)]

8. Explain What is NPM and when do you use it. provide an example illustrating use of NPM

  • What is NPM...
    • Node Package Manager (NPM) is the world's largest Software Registry.
    • npm is also a software Package Manager and Installer.

    • npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently

  • When to use NPM...

    • it is used to publish, discover, install, and develop node programs.

  • Example illustrating the use of NPM...

    • Install Modules with npm install [this npm command is used to install modules to node framework]

9.How to stop master process without suspending all of its child processes?

When using a process management system like upstart, it's entirely possible that the parent process could be respawned, creating a whole new generation of worker processes in addition to the orphaned processes. So, when the parent process dies ungracefully, none of the spawned child processes are killed.

10. What does emitter do and what is dispatcher. write example for each ?

  • Emitter:
    • The EventEmitter is a module that facilitates communication/interaction between objects in Node. EventEmitter is at the core of Node asynchronous event-driven architecture.
    • // Import events module var events = require('events'); // Create an eventEmitter object var eventEmitter = new events.EventEmitter(); 

11. Explain module.exports in Node Js ?

  • The module.exports or exports is a special object which is included in every Javascript file in the Node.js application by default. module is a variable that represents current module and exports is an object that will be exposed as a module. So, whatever you assign to module.exports or exports, will be exposed as a module.

Related Solutions

C++ language. struct Node {    int data;    Node *next; } Write a function to...
C++ language. struct Node {    int data;    Node *next; } Write a function to concatenate two linked lists. Given lists A* = (4, 6) and B* = (3, 7, 12), after return from Concatenate_Lists(Node A*, Node B*) the list A should be changed to be A = (4, 6, 3, 7, 12). Your function should not change B and should not directly link nodes from A to B (i.e. the nodes inserted into A should be copies of...
Below is for C language typedef struct _node { Node *next; char *str; } Node; You...
Below is for C language typedef struct _node { Node *next; char *str; } Node; You are given a function that takes in two Node* pointers to two different linked lists. Each linked list node has a string represented by a character array that is properly null terminated. You're function is supposed to return true if the concatenation of strings in a linked list match each other, else return false. EXAMPLES List 1: "h" -> "el" -> "l" -> "o"...
The programming language is Python Instructions: Create a function that will delete a node in a...
The programming language is Python Instructions: Create a function that will delete a node in a Linked List based on position number. On below example, if you want to delete position #2, it will remove the Banana (arrangement of nodes below is Apple, Banana, Cherry, Grapes, Orange). myLinkedList = LinkedList() myLinkedList.append("Banana") myLinkedList.append("Cherry") myLinkedList.append("Grapes") myLinkedList.append("Orange") myLinkedList.prepend("Apple") myLinkedList.deleteByPositionNum(2) node = myLinkedList.head while node: print(node.value, " ") node = node.next_node You may start with the function head: def deleteByPositionNum(self, positionNum):
What kinds of perceptual and cognitive processing is needed for understanding spoken and written language? What...
What kinds of perceptual and cognitive processing is needed for understanding spoken and written language? What neural structures are involved?
Thinking in Assembly language What values will be written to the array when the following code...
Thinking in Assembly language What values will be written to the array when the following code executes? .data array DWORD 4 DUP(0) .code main PROC mov eax,10 mov esi,0 call proc_1 add esi,4 add eax,10 mov array[esi],eax INVOKE ExitProcess,0 main ENDP proc_1 PROC call proc_2 add esi,4 add eax,10 mov array[esi],eax ret proc_1 ENDP proc_2 PROC call proc_3 add esi,4 add eax,10 mov array[esi],eax ret proc_2 ENDP proc_3 PROC mov array[esi],eax ret proc_3 ENDP
Java Language Add a method (deleteGreater ()) to the LinkedList class to delete the node with...
Java Language Add a method (deleteGreater ()) to the LinkedList class to delete the node with the higher value data. Code: class Node { int value; Node nextNode; Node(int v, Node n) { value = v; nextNode = n; } Node (int v) { this(v,null); } } class LinkedList { Node head; //head = null; LinkedList() { } int length() { Node tempPtr; int result = 0; tempPtr = head; while (tempPtr != null) { tempPtr = tempPtr.nextNode; result =...
What is machine language and how does it process input written in different scripting languages? How...
What is machine language and how does it process input written in different scripting languages? How user input is converted to output (give a detailed example) CPU ALU BIOS GPU Volatile and Non-Volatile memory What is the role of the OS?
Assume that struct Node { int item; Node* link; }; typedef Node* NodePtr; 1. Write function...
Assume that struct Node { int item; Node* link; }; typedef Node* NodePtr; 1. Write function void list_head_insert(NodePtr& head, int entry); The function should insert a new Node, in which entry is the value of attribute item, in front of the linked list that is pointed by head. 2. Write function void list_head_remove(NodePtr& head); The function will remove the first node from the linked list that is pointed by head. 3. Write function NodePtr list_search(NodePtr head, int target); The function...
This program should be written in Java language. Given the uncertainty surrounding the outbreak of the...
This program should be written in Java language. Given the uncertainty surrounding the outbreak of the Coronavirus disease (COVID-19) pandemic, our federal government has to work tirelessly to ensure the distribution of needed resources such as medical essentials, water, food supply among the states, townships, and counties in the time of crisis. You are a software engineer from the Right Resource, a company that delivers logistic solutions to local and state entities (schools, institutions, government offices, etc). You are working...
Public Speaking Discuss the differences between oral and written language styles.
Public Speaking Discuss the differences between oral and written language styles.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT