Sharing Top Content from the Angular-sphere.

awesome-cheatsheets/node.js at master · LeCoupa/awesome-cheatsheets · GitHub

  • The top-level scope is not the global scope; var something inside a Node module will be local to that module.
  • unref(); // Allow you to create a timer that is active but if it is the only item left in the event loop, node won’t keep the program running.
  • exports.area = function (r) { – – – – return Math.PI * r * r; – – – – }; – – – – – – – – – // If you want the root of your module’s export to be a function (such as a constructor) – – -…
  • module.exports = function(width) { – – – – return { – – – – area: function() { – – – – return width * width; – – – – } – – – – }; – – – – } – – – – – – – – – -…
  • process.config; // An Object containing the JavaScript representation of the configure options that were used to compile the current node executable.

awesome-cheatsheets – 📚 Awesome cheatsheets for popular programming languages, frameworks and development tools. They include everything you should know in one single file.

/*

* SYNOPSIS

*

* */

var http = require(‘http’);

// An example of a web server written with Node which responds with ‘Hello World’.

// To run the server, put the code into a file called example.js and execute it with the node program.

http.createServer(function (request, response) {

response.writeHead(200, {‘Content-Type’: ‘text/plain’});

response.end(‘Hello World\n’);

}).listen(8124);

console.log(‘Server running at http://127.0.0.1:8124/’);

awesome-cheatsheets/node.js at master · LeCoupa/awesome-cheatsheets · GitHub

Comments are closed, but trackbacks and pingbacks are open.