Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8918595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:47:46+00:00 2026-06-15T05:47:46+00:00

On the Node.js documentation we can see : var util = require(util); var events

  • 0

On the Node.js documentation we can see :

var util = require("util");
var events = require("events");

function MyStream() {
    events.EventEmitter.call(this);
}

util.inherits(MyStream, events.EventEmitter);

var stream = new MyStream();

Is it the same as :

function MyStream2() {
}
//MyStream2 = new events.EventEmitter; WRONG. Thank you @Esailija
MyStream2.prototype = new events.EventEmitter;

var stream2 = new MyStream2();

Thank you 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:47:47+00:00Added an answer on June 15, 2026 at 5:47 am

    If we edit your code to be working, that is:

    MyStream2.prototype = new events.EventEmitter;
    

    There will be still some differences:

    • In your version, MyStream2.prototype.constructor === events.EventEmitter, with inherits, MyStream2.prototype.constructor === MyStream2

    • Your version invokes events.EventEmitter constructor which could have side effects., whereas inherits uses Object.create which doesn’t invoke the constructor function.

    • Not related to the differences between chaining prototypes, but your version doesn’t call parent constructor when the child constructor is called. So it should still have function MyStream2() { events.EventEmitter.call(this); } to properly establish initial state when the child constructor is called.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can node.js listen on UNIX socket? I did not find any documentation regarding this.
Looking at the Handlebars.js documentation for precompilation. The instructions are for OSX. Can this
This is a super basic task, but I can't find documentation on it. I
I have just started studying node.js and express, the documentation of express on the
Can node.js be setup to recognize a proxy (like Fiddler for example) and route
I have code on a compute node of a cluster. I can't ssh directly
I'm having a heck of a time finding documentation on io.sockets.clients() so I can
I want to use ._get_type ( node ) function from jsTree plugin types The
Does Node.js have built-in Base64 encoding yet? The reason why I ask this is
So, I'm writing a simple function to remove a XML node from a XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.