faire_un_dump_dans_la_console
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédenteDernière révisionLes deux révisions suivantes | ||
faire_un_dump_dans_la_console [2022/11/10 20:21] – tickleman | faire_un_dump_dans_la_console [2022/11/25 13:04] – tickleman | ||
---|---|---|---|
Ligne 2: | Ligne 2: | ||
Javascript - var_dump - print_r - console | Javascript - var_dump - print_r - console | ||
+ | |||
+ | Vous pouvez copier-coller ça dans votre navigateur : ça fera un dump récursif de votre variable application (à remplacer par ce qui vous intéresse) dans un format qui va vous aider à retrouver vos données : | ||
<code javascript> | <code javascript> | ||
- | dmp = (what, pre = '', | + | dmp = (what, pre = '', |
- | if (typeof what == ' | + | if (depth === 20) anticyclic = {} |
- | return ' | + | |
- | } | + | if (typeof what == ' |
- | if (typeof what == ' | + | for (const anti in anticyclic) if (anticyclic.hasOwnProperty(anti) && (anticyclic[anti] |
- | return ' | + | |
- | } | + | if (Array.isArray(what)) { |
- | for (const anti of anticyclic) | + | |
- | if (what === anti) { | + | |
- | return ' | + | let key = 0 |
- | } | + | for (const value of what) { |
- | } | + | result += pre + ' |
- | anticyclic.push(what) | + | key ++ |
- | if (depth && | + | } |
- | let result = " | + | return result + ' |
- | let key = 0 | + | } |
- | for (const value of what) { | + | else if (typeof what === ' |
- | result += pre + ' | + | |
- | key ++ | + | |
- | } | + | for (const key in what) if (what.hasOwnProperty(key)) { |
- | return result + ' | + | result += pre + ' |
- | } | + | } |
- | else if (depth && | + | return result + ' |
- | let result = " | + | } |
- | for (const key in what) if (what.hasOwnProperty(key)) { | + | return what.toString() |
- | result += pre + ' | + | |
- | } | + | |
- | return result + ' | + | |
- | } | + | |
- | return what.toString() | + | |
} | } | ||
- | anticyclic = [] | ||
dmp(application) | dmp(application) | ||
</ | </ | ||
- | |||
- |
faire_un_dump_dans_la_console.txt · Dernière modification : 2022/11/25 13:05 de tickleman