javascript - Using an Array instead of an Object in JS -
i have below object being declared in application:
self.errors = { error: { status: 404, text: 'missing!' } }; now above object aiming grow each error triggered user, provide list of errors.
now far aware, there isn't easy way me add additional error properties errors object (so have 1 405 etc).
but experience arrays limited. there similar format use in array push additional error sections array?
this assuming there no easy way add properties objects.
edit: user's actions generate list of errors meaning can't use following structure:
self.errors = { 404: "not found", 500: "error text" }; because the list grow pretty indefinitely keep triggering errors.
your title suggest right thing. looking array of objects
self.errors = [{state:404, text: 'resource not found'}, {state:200, text: 'ok'}]
Comments
Post a Comment