Thursday, 15 January 2015

How to make JavaScript objects more readable/navigable? -


I am creating an object with a group of nested objects when working with the web inspector, You have to re-combine because all of these objects are called simply Object . A short version of my object tree looks like this:

  v object v field: array [3] v 0: object v field: array [2] v 0: object name: ' Name 'placeholder:' name 'tag:' input 'type:' text '& gt; 1: Item name: 'name' tag: 'field' & gt; 1: Object & gt; 2: Name of object: 'name'   

It gets older faster Is there any way to make it more readable / navigating? If so, is it efficient? Like this:

v code: fields [3] v 0: fieldset v fields: array [2] v 0: input name: 'name' placeholder: 'name' tags: ' Input 'type:' text '& gt; 1: Textera name: 'name' tag: 'field' & gt; 1: Fieldset & gt; 2: Button name: 'name'

Or is it something I want to settle?

To automatically expand all the properties and objects or < Code> Array [l] is not a universal technique, it is also the advantage of not changing the console after the beautifulphone JSON release is launched, when your objects are mutated. You should not do this with just a very large object, and it is impossible on cyclical objects.

  console.log (JSON.stringify (tree, blank, 4));    

No comments:

Post a Comment