JS non-enumerable function

I don't get it, why can't you access it as a method?

var foo = {};

Object.defineProperty(foo, 'bar', {
    enumerable: false,
    value: function () {console.log('foo.bar\'d!');}
});

foo.bar(); // foo.bar'd!

If you wanted it on the prototype, it's as easy as

Object.defineProperty(foo.prototype, /* etc */);

or even directly in Object.create

foo.prototype = Object.create(null, {
    'bar': {value: function () {/* ... */}}
});

However, unless you're creating instances of foo, it won't show up if you try to foo.bar, and only be visible as foo.prototype.bar.

If foo has it's own prototype (e.g. foo = Object.create({})), you can get it with Object.getPrototypeOf, add the property to that and then foo.bar would work even if it is not an instance.

var proto = Object.getPrototypeOf(foo); // get prototype
Object.defineProperty(proto, /* etc */);

You can see visibility of enumerable vs non-enumerable properties here.