Skip to main content

A more modern, ECMAScript 2015ECMAScript 2015 (formerly known as Harmony or ES 6 6) approach. Given:

const items = [1, 2, 3, 4]; const index = 2; 

Then:

items.filter((x, i) => i !== index); 

Yielding:

[1, 2, 4] 

You can use Babel and a polyfill servicepolyfill service to ensure this is well supported across browsers.

A more modern, ECMAScript 2015 (formerly known as Harmony or ES 6) approach. Given:

const items = [1, 2, 3, 4]; const index = 2; 

Then:

items.filter((x, i) => i !== index); 

Yielding:

[1, 2, 4] 

You can use Babel and a polyfill service to ensure this is well supported across browsers.

A more modern, ECMAScript 2015 (formerly known as Harmony or ES 6) approach. Given:

const items = [1, 2, 3, 4]; const index = 2; 

Then:

items.filter((x, i) => i !== index); 

Yielding:

[1, 2, 4] 

You can use Babel and a polyfill service to ensure this is well supported across browsers.

Expansion, etc.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

A more modern, ES2015ECMAScript 2015 (formerly known as Harmony or ES6ES 6) approach. GivenGiven:

const items = [1, 2, 3, 4]; const index = 2; 

Then:

items.filter((x, i) => i !== index); 

Yielding:

[1, 2, 4] 

You can use Babel and a polyfill service to ensure this is well supported across browsers.

A more modern, ES2015 (formerly known as Harmony or ES6) approach. Given:

const items = [1, 2, 3, 4]; const index = 2; 

Then:

items.filter((x, i) => i !== index); 

Yielding:

[1, 2, 4] 

You can use Babel and a polyfill service to ensure this is well supported across browsers.

A more modern, ECMAScript 2015 (formerly known as Harmony or ES 6) approach. Given:

const items = [1, 2, 3, 4]; const index = 2; 

Then:

items.filter((x, i) => i !== index); 

Yielding:

[1, 2, 4] 

You can use Babel and a polyfill service to ensure this is well supported across browsers.

Source Link
bjfletcher
  • 11.6k
  • 5
  • 58
  • 70

A more modern, ES2015 (formerly known as Harmony or ES6) approach. Given:

const items = [1, 2, 3, 4]; const index = 2; 

Then:

items.filter((x, i) => i !== index); 

Yielding:

[1, 2, 4] 

You can use Babel and a polyfill service to ensure this is well supported across browsers.