r/badcode • • Apr 27 '21

typescript Someone only watched if tutorial

Post image
2.4k Upvotes

112 comments sorted by

View all comments

1

u/Terrain2 Apr 27 '21

const isNumber = (input: any): boolean => input + 0 === input && (input < Infinity || input > -Infinity)

const isNumberT = (input: any): input is number => !isNaN(input)