Skip to content

Commit 8b4a20a

Browse files
Update NodeJS.md
Proper formatting, replaced fancy quotes
1 parent 7628c2a commit 8b4a20a

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

NodeJS.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
11
# NodeJS Interview Questions: Jordan
22

3-
NodeJS Section
3+
## NodeJS Section
44

5-
Easy
5+
### Easy
66

77
1. What engine does NodeJS run on?
8-
-Googles V8 Engine
8+
Answer: Googles V8 Engine
9+
910
2. What is the typical first parameter in a NodeJS callback function for core modules?
10-
-Typically the error object is the first parameter of a callback function
11+
Answer: Typically the error object is the first parameter of a callback function
1112

12-
Medium
13+
### Medium
1314

1415
3. How do you handle an unhandled exception in NodeJS? Use the process object to create an exception handler for these.
1516

16-
Answer:
17+
Answer:
1718

18-
process.on('uncaughtException', (err) => {
19-
console.log('Caught exception: ' + err);
20-
});
19+
process.on('uncaughtException', (err) => {
20+
console.log('Caught exception: ' + err);
21+
});
2122

2223
4. What is "callback hell"? Describe a solution methodology or modules that help resolve this issue.
2324

24-
Answer:
25-
Promises are a good methodology to solve callback hell (nested callbacks), often caused by NodeJS’s asynchronous event loop. A good library for promise handling is Bluebird, but native Promises are also an option, using the resolve, reject pattern.
25+
Answer:
26+
Promises are a good methodology to solve callback hell (nested callbacks), often caused by NodeJS’s asynchronous event loop. A good library for promise handling is Bluebird, but native Promises are also an option, using the resolve, reject pattern.
2627

27-
The async module provides a good waterfall style pattern to asynchronous methods, in an array of cascading methods. This is useful for multiple async calls, such as multiple mongodb queries that depend on each other’s results.
28+
The async module provides a good waterfall style pattern to asynchronous methods, in an array of cascading methods. This is useful for multiple async calls, such as multiple mongodb queries that depend on each other’s results.
2829

2930
5. Explain the importance of package.json and NPM for a NodeJS project.
3031

31-
Answer
32-
NPM looks for a package.json file in the structure, and when you run npm install on a project, it will find your dependencies, which are created when you install a module upon creation via npm install module --save (--sav dev is an option for development environment dependencies)
32+
Answer
33+
NPM looks for a package.json file in the structure, and when you run npm install on a project, it will find your dependencies, which are created when you install a module upon creation via npm install module --save (--sav dev is an option for development environment dependencies)
3334

34-
Hard:
35+
### Hard:
3536

3637
6. NodeJS utilizes the express framework to handle HTTP routing and other API style services. Assuming express, and bodyParse are already included, and the server is listening on port 8080, write code to expose a directory named ”public” for static material like html, css, and javascript files. Assume the express variable is named “app”. On the route (GET method) /foo, render the HTML file “foo.html”. On the route (POST method) /bar, send a small object (can be anything, content is irrelevant) response.
3738

38-
Answer:
39+
Answer:
3940

40-
app.use("/", express.static(__dirname+"/public")); //expose public dir
41-
app.get(/foo, function(req, res) {
42-
res.render(foo.html);
43-
});
44-
app.post(/bar, function(req, res) {
45-
res.send({flag:true});
46-
});
41+
app.use("/", express.static(__dirname+"/public")); //expose public dir
42+
app.get("/foo", function(req, res) {
43+
res.render("foo.html");
44+
});
45+
app.post("/bar", function(req, res) {
46+
res.send({flag:true});
47+
});

0 commit comments

Comments
 (0)