DEV Community

Discussion on: 10 javascript basics interns should know before the job

Collapse
 
loucyx profile image
Lou Cyx

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:

const coolFunction = function () { return returnValue; }; // DON'T DO THIS
const coolFunction = () => returnValue; // DO THIS
Enter fullscreen mode Exit fullscreen mode

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:

type Contact = {
    readonly address: string;
    readonly email?: string;
};

type Person = {
    readonly name: string;
    readonly contact: Contact;
};

const listOfPeople: 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.
 */
const findPersonEmailByName = (name: string) =>
    listOfPeople.find(
        person => person.name.toLocaleLowerCase() === name.toLocaleLowerCase(),
    )?.contact.email;
Enter fullscreen mode Exit fullscreen mode

We also rely more in type inference, and type only what's needed.

Cheers!

Collapse
 
omills profile image
Olivier

Thanks for taking the time to provide such great feedback! I have updated the post.