I'm working on a new OOP model for JavaScript and I'm wondering whether you consider it right to make methods on objects enumerable or only the data members. I can see some sense in both and maybe there is no definite answer.
Can also make the own methods enumerable and the inherited ones not...
That said I feel it makes sense anyways to make all data members enumerable even if they are inherited.
update: this seemed not clear from what people are answering. I am creating a OOP model which will allow users to write something like this to declare a class:
update 2: in the mean time the project is out and about, this is what it has become: OoJs. In it, user defined properties including methods are enumerable, properties added by the framework aren't.
;(function( namespace )
{
'use strict';
namespace.Shape = Shape
var Static = namespace.OoJs.setupClass( "Shape" )
// Data members
//
Static.canvas = null
Static.Protected( "canvas" ) // Protected members
Static.Public () // Public members
// constructor
//
function Shape()
{
// Data members
//
this.sides = null
// Private methods
//
this.init = init
this.Protected( "sides" ) // Protected members
var iFace = this.Public( getOffset ) // Public interface
this.init() // for example
return iFace
}
// Method definitions
//
function init (){ /*do something useful*/ }
function getOffset(){ return [ this.x, this.y ] }
})( window )
So the question is if you would use this to declare your classes, would you assume/want methods to be enumerable or not or should there be a way to configure either classwide or per member whether it should be enumerable not?