atfinho
2 months ago
991
3
Vue

Push to array without add key

Posted 2 months ago by atfinho

Hey guys I would like to know how can I remove keys from an array .. For example this is an array : ['0' => 'value 0 ' , '1' =>'value 1 ']

I want just to display ['value 0', 'value 1' ]

I have this array


    data(){

     return{

     deleteMultiple:[]
            
}
    },

Then I'm trying to gather a specific ids to delete them later

    addDeleteItems(id,event){
                        if (!event.target.checked) {
                        let i = this.deleteMultiple.map(item => item.id).indexOf(id) // find index of your object
                        this.deleteMultiple.splice(i, 1) // remove it from array
                          }
                          else{
                            alert(id);
                              this.deleteMultiple.push(id);

                          }
                       },

I'm getting always that output even though I use push...

Please sign in or create an account to participate in this conversation.