Skip to main content
added 2 characters in body
Source Link
NeNaD
  • 20.9k
  • 11
  • 66
  • 120

Update - 27 October 2021 (Chrome 97+)

Proposal for Array.prototype.findLast is now on Stage 3!

Here's how you can use it:

const array = [1, 2, 3, 4, 5];

const last_element = array.findLast((item) => true);
console.log(last_element);

You can read more in this V8 blog post.

You can find more in "New in Chrome" series.

Update 27 October 2021

Proposal for Array.prototype.findLast is now on Stage 3!

Here's how you can use it:

const array = [1, 2, 3, 4, 5];

const last_element = array.findLast((item) => true);
console.log(last_element)

Update - 27 October 2021 (Chrome 97+)

Proposal for Array.prototype.findLast is now on Stage 3!

Here's how you can use it:

const array = [1, 2, 3, 4, 5];

const last_element = array.findLast((item) => true);
console.log(last_element);

You can read more in this V8 blog post.

You can find more in "New in Chrome" series.

added 106 characters in body
Source Link
NeNaD
  • 20.9k
  • 11
  • 66
  • 120

Update 27 October 2021

YouProposal for Array.prototype.findLast is now on Stage 3!

Here's how you can now use Array.prototype.findLastit:

const array = [1, 2, 3, 4, 5];

const last_element = array.findLast((item) => true);
console.log(last_element)

Update 27 October 2021

You can now use Array.prototype.findLast:

const array = [1, 2, 3, 4, 5];

const last_element = array.findLast((item) => true);
console.log(last_element)

Update 27 October 2021

Proposal for Array.prototype.findLast is now on Stage 3!

Here's how you can use it:

const array = [1, 2, 3, 4, 5];

const last_element = array.findLast((item) => true);
console.log(last_element)

deleted 20 characters in body
Source Link
NeNaD
  • 20.9k
  • 11
  • 66
  • 120

Update 27 October 2021

You can now use Array.prototype.findLast:

const array = [
  { id: 1, name: 'Item 1' },
  { id: 2, name: 'Item 2' },
  { id: 3, name: 'Item 3' },
  { id: 4, name: 'Item 4' },
  { id: 5, name: 'Item 5' }
]

let last_element = array.findLast((item) => true);
// → { id: 5, name: 'Item 5' }

const array = [1, 2, 3, 4, 5];

const last_element = array.findLast((item) => true);
console.log(last_element)

Update 27 October 2021

You can now use Array.prototype.findLast:

const array = [
  { id: 1, name: 'Item 1' },
  { id: 2, name: 'Item 2' },
  { id: 3, name: 'Item 3' },
  { id: 4, name: 'Item 4' },
  { id: 5, name: 'Item 5' }
]

let last_element = array.findLast((item) => true);
// → { id: 5, name: 'Item 5' }

Update 27 October 2021

You can now use Array.prototype.findLast:

const array = [1, 2, 3, 4, 5];

const last_element = array.findLast((item) => true);
console.log(last_element)

Source Link
NeNaD
  • 20.9k
  • 11
  • 66
  • 120
Loading