
[#es6 #class #proto] - giowe
Hi guys. I&#x27;m working on a node module and i would like to keep using es6 classes syntax for style consistency but i found this pattern that I can&#x27;t reproduce:<p>```
const proto = module.exports = function(options) {
  man.opts = options || {};
  function cane(sentence) {
    man.say(sentence);
  }<p><pre><code>  man.__proto__ = proto;
  man.age = 29;
  man.say = function(sentence) {
    console.log(sentence);
  };
  return man;</code></pre>
};
```<p>The strange thing of this function is that I can call it as a standard constructor and get a man with his methods and props but I can also call man as a function and get the same result as calling his method &quot;say&quot;.
Basically man(&#x27;text&#x27;) produces the same effect of man.say(&#x27;text&#x27;);
How can I recreate this pattern using es6 classes syntax?
======
andrewmcwatters
Stack Overflow is a more appropriate place for this.

~~~
giowe
yup

