QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 50

Given [1, 2, 3, 4].filter(x => x > 2), which result is returned?

  1. [false, false, true, true]
  2. [3, 4]Ճիշտ պատասխան
  3. [1, 2]
  4. true

Բացատրություն

filter keeps the original element values whose callback results are truthy, so it returns 3 and 4 in a new array. It does not collect the callback's true and false results as map would collect callback outputs.

Շարունակեք այս թեստով

Սկսել վարժանքը
Հարց 50: Given [1, 2, 3, 4].filter(x => x > 2), which result is… · JavaScript Fundamentals · Questena