concept object in category node

appears as: objects, object, n object, object, The object, The objects, objects
Node.js in Action, Second Edition

This is an excerpt from Manning's book Node.js in Action, Second Edition.

When deciding whether to use const or let, you almost always want const. Because most of your code will use instances of your own classes, object literals, or values that don’t change, you can use const most of the time. Even instances of objects that have properties that change can be declared with const, because const means only that the reference is read-only, not that the value is immutable.

mixin list_object_property(objects, property)
  ul
    each object in objects
      li= object[property]
hapi.js in Action

This is an excerpt from Manning's book hapi.js in Action.

The first route calls reply() with a string and the second with an object. hapi is smart enough to know that I want the first case to be a response type of text/plain and the second case to be a response type of application/json and will set the response Content-type headers automatically. This is an example of hapi making sensible assumptions for you.

When we call the reply interface to set a response to the client, we can pass reply() a variety of different data types. We’ve already seen many examples of calling reply() with strings and with objects. Other values can be set as responses too. There’s a full list in table 5.2, along with the corresponding behavior by hapi.

TypeError: Object [object Object] has no method 'views'
Node.js in Practice

This is an excerpt from Manning's book Node.js in Practice.

Streams inherit from EventEmitter and can be used to model data with unpredictable throughput—like a network connection where data speeds can vary depending on what other users on the network are doing. Using Node’s stream API allows you to create an object that receives events about the connection: data for when new data comes in, end when there’s no more data, and error when errors occur.

The easiest way to solve this problem is to use an object to act as a central dictionary for all of the event names. This creates a centralized location of each event in the project.

It’s hard to keep track of event names littered throughout a project. One way to manage this is to keep each event name in one place. Listing 4.14 demonstrates using an object to categorize event names, based on the previous examples in this chapter.

Listing 4.14. Categorizing event names using an object
events.js:72
  throw er; // Unhandled 'error' event
 ^
Error: No handler to catch me
  at Object.<anonymous> (/debugging/domain/ee.js:5:18)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:902:3