Skip to content

Instantly share code, notes, and snippets.

@munkacsitomi
Last active February 3, 2022 10:36
Show Gist options
  • Save munkacsitomi/d2c2908db2f810504b6bfe6977d3265b to your computer and use it in GitHub Desktop.
Save munkacsitomi/d2c2908db2f810504b6bfe6977d3265b to your computer and use it in GitHub Desktop.
Map types
const stringNumbers = ['123', '4.45', '5,25', 'abc', '10000'];
const numbers = stringNumbers.map(Number);
console.log(numbers); // [123, 4.45, NaN, NaN, 10000]
const stringBoolean = ['false', false, '0', 0, null, undefined];
const booleans = stringBoolean.map(Boolean);
console.log(booleans); // [true, false, true, false, false, false]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment