well if you really want the constructor to only receive string, you can just throw an error if the parameter is not a string with "typeof"
if(typeof name !== 'string') throw Error('Only string is allowed you mother fucker');
but nowadays devs use Typescript instead, they can just config the compiler to fail the build if it's violate TS rules, like passing number into string
well if you really want the constructor to only receive string, you can just throw an error if the parameter is not a string with "typeof"
if(typeof name !== 'string') throw Error('Only string is allowed you mother fucker');
but nowadays devs use Typescript instead, they can just config the compiler to fail the build if it's violate TS rules, like passing number into string
thanks
I guess I'm not a dev then. Hmm?