Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js - overloading functions

Is there a way to overload functions in node.js similar to __noSuchMethod__ ?

like image 724
Andrei Serdeliuc ॐ Avatar asked Aug 26 '26 10:08

Andrei Serdeliuc ॐ


2 Answers

Like bxjx briefly mentioned, Node.js is based on Google's V8 javascript engine, meaning that any language constructs or features come from that. Seeing as it is non-standard, i don't think they will add it in the near future. Also i don't think Node will ever base itself on a non-official V8 fork, but who knows. You can still use that fork yourself.

like image 119
Tor Valamo Avatar answered Aug 28 '26 00:08

Tor Valamo


That would be cool. It would open up DSL like capabilities found in ruby.

According to this conversation on the node.js google group, it's probably not going to happen. I can't think of another way around it without object.send('method'), but maybe it's possible.

Looks like people have forked V8 to add this sort of thing.

like image 20
bxjx Avatar answered Aug 27 '26 23:08

bxjx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!