Yes, learn typescript before getting any javascript job
I love TypeScript, and use it since it's first public release in 2012, and yet I don't agree with this statement. If the interview is about JavaScript and they ask about TypeScript, run away from there. You can still learn TypeScript, just avoid places where they say they are looking for JS devs and then they ask you about TS.
Arrow functions
Your snippet has a typo in the first part:
constcoolFunction=function(){returnreturnValue;};// DON'T DO THISconstcoolFunction=()=>returnValue;// DO THIS
And I would say "favor arrow functions over regular functions", but I wouldn't say "don't do regular functions", because they might be useful in some scenarios.
Template literals
Nothing wrong with the snippet, just that you could do ?? instead of ||.
Lodash
Not a requirement at all, even more so when pretty much everything you might need is already in vanilla JS.
Finally, the last example has some typos as well (the return type of the function isn't Person, you didn't specify the type of the name that function takes, etc). Here's a fixed version:
typeContact={readonlyaddress:string;readonlyemail?:string;};typePerson={readonlyname:string;readonlycontact:Contact;};constlistOfPeople:ReadonlyArray<Person>=[];/**
* Find a person's email by name (case insensitive).
*
* @param name Name you are looking for.
* @returns The person's email or `undefined` if not found.
*/constfindPersonEmailByName=(name:string)=>listOfPeople.find(person=>person.name.toLocaleLowerCase()===name.toLocaleLowerCase(),)?.contact.email;
We also rely more in type inference, and type only what's needed.
I love TypeScript, and use it since it's first public release in 2012, and yet I don't agree with this statement. If the interview is about JavaScript and they ask about TypeScript, run away from there. You can still learn TypeScript, just avoid places where they say they are looking for JS devs and then they ask you about TS.
Your snippet has a typo in the first part:
And I would say "favor arrow functions over regular functions", but I wouldn't say "don't do regular functions", because they might be useful in some scenarios.
Nothing wrong with the snippet, just that you could do
??instead of||.Not a requirement at all, even more so when pretty much everything you might need is already in vanilla JS.
Finally, the last example has some typos as well (the return type of the function isn't
Person, you didn't specify the type of thenamethat function takes, etc). Here's a fixed version:We also rely more in type inference, and type only what's needed.
Cheers!
Thanks for taking the time to provide such great feedback! I have updated the post.