Linked Questions

Popular Questions

How to get first N number of elements from an array

Asked by At

I am working with Javascript(ES6) /FaceBook react and trying to get the first 3 elements of an array that varies in size. I would like do the equivalent of Linq take(n).

In my Jsx file I have the following:

var items = => {
  return (
    <myview item={i} key={} />

Then to get the first 3 items I tried

  var map = new Map(list);
    map.size = 3;
    var items = map(i => {
      return (<SpotlightLandingGlobalInboxItem item={i} key={} />);

This didn't work as map doesn't have a set function.

Can you please help?

Related Questions