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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -