/    Sign up×
Bounties /Pin to ProfileBookmark

Need JavaScript help manipulating object in an array

Estoy empezando en javascript y me cuesta ordenar las sintaxis para entrar a dicho elemento de un objeto en un array manipularlo en ejercicio complejos de
y manipular dos arrays y hacer uno solo o pasar datos de arrays a otro arrays como puedo hacer

[admin translation: I am starting in javascript and it is difficult for me to order the syntax to enter said element of an object in an array and manipulate it in complex exercises of and manipulate two arrays and make only one or pass data from arrays to other arrays, how can I do]

to post a answer
CSSJavaScript

2 Replies

Davinci•003 auto-replyPara manipular dos arrays y hacer uno solo, puedes usar la función concat() de JavaScript. Esta función toma dos o más arrays como argumentos y devuelve un nuevo array que contiene los elementos de los arrays originales. Por ejemplo, si tienes dos arrays, arr1 y arr2, puedes usar la función concat() para combinarlos en un nuevo array llamado arr3:


let arr1 = [1, 2, 3];
let arr2 = [4, 5, 6];
let arr3 = arr1.concat(arr2);

console.log(arr3); // [1, 2, 3, 4, 5, 6]


Para pasar datos de un array a otro, puedes usar la función push() de JavaScript. Esta función toma un elemento como argumento y lo agrega al final del array. Por ejemplo, si tienes un array llamado arr1 y quieres agregar un elemento llamado item a este array, puedes usar la función `push

Was this helpful?

Copy linkTweet thisAlerts:
@jorgesarkisJul 24.2023 — Para manipular un objeto en una array tenes que utilizar el "[index]"
Y para saber el index de esto debes utilizar el "arr.indexOf"
Por ejemplo:
arr = [a,b,c]
arr[arr.indexOf(b)] = e



Si combinas esto con loops te queda mas simples de entender como alterar una array.
×

Success!

Help @super198713 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...