Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

137
Visualizações
I'm getting an object even though I'm returning an array from my javascript function

I have a function in a javascript file where I return an array. But when I call this function, when I look at the type with the "typeof" command, it returns an object instead of an array.

My javascript file is here.

import {useStore} from "vuex";
import {computed} from "vue";

export const getActions = (menuId) => {
   const store = useStore()
    const loginInfo = computed(() => {
        return store.state.Identity.loginInfo
    });
    const actions = []
    loginInfo.value.Authorization.forEach((x)=>{
        let splitData = x.Id.split('-')
        if(splitData[0] === '02' && splitData[1] === menuId){
            if(!actions.some(item => item.Id === splitData[2]))
                actions.push({
                    Id:splitData[2],
                    Definition: x.Definition,
                    Clicked:false
                })
        }
    })
    return actions;
}

Here is where I call and use this function.

 let actions =[]
    actions =  getActions(props.menuId)
      for(let i=0; actions.length;i++){
        if(props.actionId === actions[i].Id)
          return isAuth.value = false
        else
          isAuth.value = true
      }

Although my variable named actions is an array, it sees it as an object and my computer starts freezing. My computer's fan starts running very fast and chrome starts to freeze.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You didn't set your loop right:

for(let i = 0; i < actions.length; i++){
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda