S
S
Sergey Levchenko2021-05-28 14:24:38
JavaScript
Sergey Levchenko, 2021-05-28 14:24:38

How to use a function from an array?

Such a question is how to make it so that you can use a function from an array, for example

let pit = function (e) {
    for (let i = 0; i < e.length; i++) {
        console.log(e[i]);
    };
};
let arr = ['Sergey', 'Dasha', 'Valera', 'Grigorii', pit];
let fun = arr[4];

arr[4](document.getElementsByClassName("btn")[0]);
так ? или может
fun(document.getElementsByClassName("btn")[0]);

I need to pass an argument to a function that is in an array

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
smigles, 2021-05-28
@smigles

Both options are possible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question