“JS Encontre objeto que tenha chave na matriz” Respostas de código

Como verificar se o objeto tem o chave JavaScript

myObj.hasOwnProperty('key') // it checks object for particular key and not on prototype   
Proud Pony

JS Encontre objeto que tenha chave na matriz

myArray.find(x => x.id === '45').foo;
Vincent Lab

As chaves do objeto incluem alguma chave

var obj = {
    test: "",
    locals: {
        test: "",
        test2: false,
        test3: NaN,
        test4: 0,
        test5: undefined,
        auth: {
            user: "hw"
        }
    }
}

keyExistsOn(obj, "")
> false
keyExistsOn(obj, "locals.test")
> true
keyExistsOn(obj, "locals.test2")
> true
keyExistsOn(obj, "locals.test3")
> true
keyExistsOn(obj, "locals.test4")
> true
keyExistsOn(obj, "locals.test5")
> true
keyExistsOn(obj, "sdsdf")
false
keyExistsOn(obj, "sdsdf.rtsd")
false
keyExistsOn(obj, "sdsdf.234d")
false
keyExistsOn(obj, "2134.sdsdf.234d")
false
keyExistsOn(obj, "locals")
true
keyExistsOn(obj, "locals.")
false
keyExistsOn(obj, "locals.auth")
true
keyExistsOn(obj, "locals.autht")
false
keyExistsOn(obj, "locals.auth.")
false
keyExistsOn(obj, "locals.auth.user")
true
keyExistsOn(obj, "locals.auth.userr")
false
keyExistsOn(obj, "locals.auth.user.")
false
keyExistsOn(obj, "locals.auth.user")
true
Jolly Jellyfish

Respostas semelhantes a “JS Encontre objeto que tenha chave na matriz”

Perguntas semelhantes a “JS Encontre objeto que tenha chave na matriz”

Mais respostas relacionadas para “JS Encontre objeto que tenha chave na matriz” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código