Outils pour utilisateurs

Outils du site


faire_un_dump_dans_la_console

Faire un dump dans la 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 :

dmp = (what, pre = '', depth = 100) => {
    if (depth === 100) anticyclic = {}
    if (typeof what == 'undefined') return '*undefined*'
    if (typeof what == 'null') return '*null*'
    for (const anti in anticyclic) if (anticyclic.hasOwnProperty(anti) && (anticyclic[anti] === what)) return '*cycle* ' + anti
    if (!depth) return what.toString()
    if (Array.isArray(what)) {
        anticyclic[pre] = what
        let result = "Array: [\n"
        let key = 0
        for (const value of what) {
            result += pre + '.' + key + ': ' + dmp(value, pre + '.' + key, depth - 1) + "\n"
            key ++
        }
        return result + ']'
    }
    else if (typeof what === 'object') {
        anticyclic[pre] = what
        let result = "Object: {\n"
        for (const key in what) if (what.hasOwnProperty(key)) {
            result += pre + '.' + key + ': ' + dmp(what[key], pre + '.' + key, depth - 1) + "\n"
        }
        return result + '}'
    }
    return what.toString()
}
dmp(application)
faire_un_dump_dans_la_console.txt · Dernière modification : 2022/11/25 13:05 de tickleman