Answer the question
In order to leave comments, you need to log in
Passing functions as an argument, how to use the same passed object, passed along with these functions in them?
How can I use the same people object in both the query function and the select and filterIn functions?
var lib = {
query: query,
select: select,
filterIn: filterIn
};
function query(collection) {
//Сюда получаем
}
function select() {
// Как использовать тот же или копию collection что мы получили в query в этой функции?
}
function filterIn(property, values) {
// Как использовать тот же или копию collection что мы получили в query в этой функции?
}
var people = [
{
name: 'Андрей',
gender: 'Мужской',
email: '[email protected]',
},
{
name: 'Николай',
gender: 'Мужской',
email: '[email protected]',
}
]
var result = lib.query(
people,
lib.select('name', 'gender'),
lib.filterIn('name', ['Андрей', 'Николай'])
);
Answer the question
In order to leave comments, you need to log in
Write one common function, pass an object into it, and use these functions inside and it is desirable to declare them as: '_query()', '_select()', etc. Add '_' in general. This designation is used if you need to show that these functions are needed only inside the object / class and outside it you do not need to use them
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question