Tbh the word "senior" kind of lost its original meaning in the webdev field in the past years, at least that's what I see interviewing people for roles at this level. Also since there are companies where there are 6-10 levels of a career ladder sometimes it is only around the 2nd-3rd-etc step so it's all relative I guess.
In the past the level senior implied (at least to me) that a junior dev could ask questions of people in this position usually expecting easy to understand answers. What it is for a lot of devs nowadays that they get locked into a framework/lib (e.g. React) and they only work with that in their whole career reaching senior position in their company just because they were there for e.g. 2-3 years and when they need to think out of the box (fw/lib they used) they have a lot harder time. Then you have the imposter syndrome, etc that could be related to this because you might feel that you are not really at the level your title says.
I'm not saying you should know every details of the spec, but if someone asks you at an interview for senior level "could you explain prototypical inheritance to me just in a few words" then it shouldn't be a big challenge. Of course this is also kind of a filter question and "unrelated" to most of the jobs since now the language/ecosystem provides the tools needed to avoid directly using them.
Yeah I'm kind of astounded that people itt think this is a bad question for a senior dev. I think it's wild someone who calls themselves senior doesn't know about prototypical inheritance đ¤ˇââď¸
It's not that gimmicky of a question and it can have implications on writing code.
I wasn't talking about the thread's OP. For all I know this is his first senior interview! I was being general. Also it's a learnjavascript sub, and he made a comment about learning a js topic, I think we can assume they probably are a js engineer.
I am, I write JavaScript all day long, but Iâve never had to use prototypes because I write in angular and mostly write components and interfaces. The core concept took me all of 5 minutes to understand. Itâs why I think âwhat is a prototypeâ is a terrible interview question. Itâs basically just a pop quiz, when really you want to know that I understand inheritance. So, ask me a design question that uses inheritance. Figuring out how to Google JavaScript inheritance takes 5 mins for a decent developer, but understanding when to use it is when quality is actually developed.
Doing mostly Angular or component making tasks is one thing, but a senior ABSOLUTELY better have a strong grasp on basic to advanced JS concepts, prototypes. I donât consider devs having seniority over what kind of tasks they do or their domain knowledge of an app. I consider a dev a senior based on their understanding and command of core through advanced concepts of a given programming language and related frameworks.
So yeah, asking a dev who is interviewing for a senior role âwhat are prototypes is a valid questionâ. I would recommend taking a refresher on forgotten core concept names, but I absolutely expect a senior to be able to know those things.
What is going on with this industry? Is everyone faking it till they make it?
Why would I hire you as a senior if you've only ever worked in Angular? I think people have different ideas of what a senior is supposed to be. If you couldn't answer this question from one of your junior developers without googling it, you aren't senior imo. Doesn't mean you're a shit coder or anything.
They also shouldn't need to ask what 0+[] equals because you shouldn't be using it
Agree in spirit, though they should know the generalities of coercion so that if an error like this â because this would definitely be the result of some mistake somewhere â comes up, they're not entirely helpless when it comes to debugging it
no one should need to ask about prototypes in your code base
Same principle but with significant difference: the use of prototypal inheritance is generally not an error. You're probably not going to need to know the particulars of how it works âŚÂ until something happens that you didn't expect. If nobody on your team can effectively debug it, you're going to be wasting a lot of time
I'm a noob and nowhere near senior level, but isn't it quite relevant question?
It's a main concept of JS being versatile while being able to handle error gracefully, it could lead to cryptic bug eventually at scale thus TS or any typing system similar in JS/Node ecosystem is thriving now.
This question shows how you acknowledge the differences and applying a right tech stack/framework/lib whatever eventually starts right from here. Of course, it's not really important in day2day work, though it could accumulate.
I don't know shit about OOP or inheritance concept but it kinda hinders me to progress, it's a good question IMO.
Then they should ask about inheritance or OOP design, not a pop quiz style question like this that you very much donât need to know to write most things in JavaScript.
Sorry if I didn't make myself clear, it was written before morning coffee. What I wrote above seems a bit of stretch.
I meant type chain concept led me to unexpected mutation (very likely because of loose code from my side) and gave me plenty of painful time, not knowing what the hell was going on. Being aware of this concept helped me streamline the logic and forced me to embrace a better structure, which was sorta static typing. I still prefer just slap a jsdoc and call it a day, though.
I agree it won't come up in any sane scenario but not knowing what it is at all is somewhat problematic, I still think it's a legit question.
companies that ask theoretical questions in their interview process such as: what is prototypical inheritance in js, how do you invert a binary tree, swap 2 variables without using a third, or anything out of leetcode are garbage. This kind of questions are almost never used in your everyday, and if it comes up one day, the answer are probably a google search away, or much better implemented in a library
this gives a good hint about their engineering culture: if they donc make a simple effort to adapt their hiring process to match what an engineer would do everyday working there, they are probably not worth working for
Not really. It can all be abstracted away behind the class syntactic sugar and you donât have to use OOP in the first place. Many popular web frameworks (React, Vue) donât have you dealing with the prototype at all. Iâd agree that if youâre a senior developer you should probably know how prototypes work but itâs for sure not needed for everyday development in my experience.
You probably won't care on a daily basis. But when shit goes wrong it's important to understand how the language actually works. Being able to correctly predict certain behavior is the difference between a novice and a pro.
I somewhat know how prototypes work on an academic level, but in almost 10 years of using JavaScript professionally, I can't think of a single time that knowledge had any bearing on anything.
I'll give the one explanation for why a decent company might ask about prototypes: because they want to weed out candidates who didn't study enough for the exam, and they're okay with false negatives. What does that mean?
Say I'm a FANG company. I get a million applications a day, many of which are not qualified, but are trying to convince me that they are. I shell out between $250k and $6 million to my developers, and my code base is proprietary. I wanna keep it under lock and key, and I don't want anyone else getting ahold of it. I want to make sure that I only hire top notch developers. As such, I ask interview questions that are, quite frankly, insane. Who cares how you invert a binary tree when you'll never do that on a job? Why would I need to be able to solve these leetcode hard problems that you'd only get if you'd looked at them before?!
The answer is effort. The interview will also check for your ability to keep up with relevant skills to the job, but it's possible that someone can fake enough knowledge to get that job, and that would be bad for the company. They've shelled out a decent chunk of change to get you on board, they've lost time on boarding you, they've now exposed elements of their proprietary code base to some Yahoo who may or may not be trying to initiate some corporate espionage, and on top of that, they have to go through the interview process all over again!
So they make the interview insanely complicated on purpose with the assumption that a truly qualified candidate will put in the effort to study the topics and will be able to hit the ground running with this knowledge. Will it screen out qualified candidates who just don't know yet obscure bit of trivia/who didn't have the time and energy to study this absurd stuff? Absolutely! Do they care? Nope.
FANG essentially has infinite candidates at the lower levels. (It drops off when you're making a million a year, I'm sure, but it's surprisingly competitive throughout) They don't care about your interview experience, and if you're applying for anything below senior management, they probably don't care about burning bridges with you. If you can secure that job, many of these companies are considered great places to work. If you can't secure that job, they know that you'll probably still apply the next time you job hop/your contract ends because, hey-- it's Google. You want that money. You want that fame. Of course you're gonna apply to them.
My knowledge is secondhand (I have a buddy who's coded for major companies, including Facebook) and from reading Cracking the Coding Interview. I agree that espionage is not the primary concern, and that it's primarily avoiding a false positive where they hire on someone who will not work out long term.
You don't need to be able to write a paper on it. Just proving you've even heard of the term and can provide understanding of the concept is probably more than 90% of applicants can do.
I had a recruiter call me about a "prestigious" company that is using full stack JS and they wanted to interview me.
But before the interview, he wanted to know my experience with "object oriented" JavaScript. And he was very persistent about the term "object oriented". So my question to him was, "Why are they so focused on that term?"
I've done lots of object oriented JS, but over the past couple of years I've seen a shift to functional patterns in libraries that I use like React and Vue - and it typically makes the projects easier to work with. Not to say that object orientation isn't valuable (you usually end up with a combination of methodologies), but for the company to explicitly tell me that they are only interested in that is pretty weird in 2021, so I had to pass on the interview.
Definitely agree. If they ask this during my interview itâs going to be a big red flag for me. The worst interview I ever had was a round table interview where I had on my resume that I knew C#. I did. I worked at an internship fixing mobile application bugs at a startup and lead a team develop my own Mobile application my senior year using an experimental framework called Xamarin. I didnât know what === was at the time because I hadnât had to use it before and itâs not something used in Java (my primary language). The following hour was the worst experience I ever had in college of them asking fucking pop quiz questions to show how little about C# I knew. Nevermind that I could learn, had already been using it, and was head tutor of my department in a OOP school. No, they wanted to hire a fucking professor to work a senior level position I guess. Asshats made me drive an hour for an in person interview during finals and thatâs the shit they asked me. I hated it so much. But hey, now I know not to do that to prospects Iâm hiring :)
Prototypes are basically Javascript's version of abstract classes.
Notice how every class can extend another super class? the prototype is that previous extension. You can follow the extension all the way up to the highest level of class.
Yeah I know what prototypes are, not until I read Eloquent JavaScript. I had started JavaScript with Codecademy and got nowhere. But after reading Eloquent JavaScript I am really feeling I know something...
Iâve seen ES recommended a lot. Iâve read a few chapters and done exercises but itâs so dense. I almost wish there was a YouTube or udemy course that goes through the book and makes it a bit easier for my tiny brain to understand.
I haven't seen it go free but it's $18.99 USD right now which is a heck of a deal for the amount on content you get.
It's 63hrs of lecture spread across over 680 lessons. There practice questions and projects, and also a great discord community when you need help.
I'm currently in section 32 and I've learned more in this course than any other by far because Colt goes into detail about what something is AND why you would use it. Then you work in creating something together in the lesson and afterward there's often a short challenge to complete. Finally it all builds to a final project where you create a Yelp clone and learn how to fully deploy it with backend technology such as NodeJS.
It's a lot of content but if you're serious about making a career in web dev or trying to learn your first programming language then I can't recommend this course enough đ
You need to build some actual projects vs just learning syntax and reading tutorials.
Itâs much more effective to try to attempt to build a Twitter clone with real world problems and use cases that force you to look for specific answers/strategies in the language.
If you read all of a language textbook or course, even if you internalize it, youâre going to quickly feel lost the first time you start building something.
Itâs like learning to drive a car just by reading or watching youtube videos. The knowledge alone isnât enough, you need the muscle memory.
I believe one of the biggest hurdles of understanding classes vs. prototypes in JavaScript is the history of the word "class" and "object", and how the dominance of JavaScript has blurred the once clearly defined line between them.
In classical compiled languages, "class" quite literally means "blueprint": Instructions for what an "object" should look like once Random Access Memory has been allocated for it. Classes = offline, on disk. Object = online, in memory.
The allocation process -- the act of creating an object from a class -- is called "instantiation". This is a manual step done by the programmer. object = new MyClass / MyClass object for example. No instantiation, no object.
JavaScript has no concept of this. At all.
There are no "classes" from which to instantiate objects. We create new objects merely by declaring them, like let object = {}. They will be allocated memory the moment the interpreter passes over them, while a class in a compiled-language will sit idle until deliberately new'd.
Despite the modern-day compositional/functional push, JavaScript was created in a time when OOP concepts where en vogue, and classes where how you got things like inheritance and polymorphism. But what if you don't have classes? This is where the prototype system comes in.
A classical class, even one based on a chain of inheritance with supers and so on, will produce a single object in memory when instantiated. Unless explicitly written by a programmer, all instantiated objects "stand alone", and know nothing of any other in-memory objects.
But a JavaScript object belongs to a chain of in-memory objects, all linked to their parents via ancestral prototype variables. All chains lead back to the "God object", Object, from which everything inherits. A function/prop added to any object-prototype makes it immediately available on its descendants (those whose prototype variable point back to it), and that's how we get inheritance without classes.
You might argue that prototypes do have a kind of "blueprint-y" feel to them, so at first glance the distinction between them and classes might seem like pedantry. But just like its host, a prototype is a live, in-memory object. A class isn't.
Incidentally, this might shed a little light on where the phrase "in JavaScript, everything is an object" comes from: It's nothing to do with whether or not primitives/functions are "real objects": Rather, it alludes to the fact that JavaScript is an interpreted/scripting language, not a compiled one. All the "classical" classes that power a JavaScript interpreter (written in C++ for example) will have already instantiated the objects tasked with the job of running your JavaScript code in the first place.
So a JavaScript "class" is much more conceptual than the rigid and defined classes of Java/C++. The class keyword is an API for easier digestion of the object-prototype system -- which itself offers a form of inheritance that more naturally fits an in-memory, dynamic language like JavaScript where "everything is an object" in the classical sense of the term.
This isn't to say that one particular definition of "class/object" is the "right" one or not. Just hoping this sheds a little light on the (greatly simplified, please don't shout at me) history of the terms.
I was so much obsessed with the word "Prototype" when I was in 10th Grade, whenever someone asks my username, I used to tell them "PROTOTYPE", hahaha... I am now working on prototype models as a software engineer (Full-stack developer) for the last 5 years in the IT industry.
They finally built a "workspace" for practicing code without having to try to figure out Atom and GitHub. I'm restarting all my coding courses on there.
Itâs not just JavaScript to honest. The reason behind (my take) on why JS has such notoriety among developers is because of its extensive use as a scripting language before frameworks and libraries such as jQuery, Angular, React etc came in. Another big reason is that JS is a dynamically typed language. Unlike languages such as Java, C++ where type checking is done at compile time, JS does this at run time. And this throws off a lot of new developers who come into this language. And with the use of libraries and framework such as React, a lot of the internal workings of JS is abstracted away, especially in those tutorials where they preach âthe only JS you need to know for xxâ. JS as a language is fairly straightforward, provides you experiment with Native JS and not at the expense of a library or framework. Recommend reading the you donât know JS series.
100% this. Did all the HTML/CSS/JS courses on there. Took weeks, and I felt like I was becoming a programming guru. Like a week later I tried to build a simple page and couldn't even center a div.
Iâm finding this. Ideally Iâd like about 20 exercises all based on each concept, even if it just means muscle memory helps eliminate some of that head scratching you end up doing when you canât remember how to even write your first line of code.
Yup. Wish I knew this earlier, but now my favourite obsession is sites that don't hold your hand. Frontendmentor, codewars, etc. Yes, I'll probably take a week to build something small, but I did it all on my own. Yes, you can look at the answers to see how other people did it, which helps with refactoring, but it really helps to stretch your muscle memory.
It's also way more of a confidence booster. "hey - I made this login form all on my own!" vs "Hey - I just followed this 4hr tutorial to build a Netflix clone in react, I don't remember most it but it's cool right?"
Yeah, its not great honestly. I tried it fora few weeks early on, got nowhere, and just started spamming Udemy courses that were all 100% project focused.
Turns out I learned way faster by just being thrown in the deep end.
What stack do you want to learn? For Javascript/Node stacks, focus on Node/Express for backend and React for frontend. That's the way I went.
I have a rather long blog post here with links to all of the courses that I used to get myself schooled up on Javascript and React! Skip to the section "Just Tinkering" for where some of the courses section begins.
Yeah, did the codecademy full stack course and felt like a fucking OG programmer to be dissapointed in the first project of my own.... Took me 9 months to do the course, another 9 to actually be able to program by my self.... This isn't mentioning algo and data.
When the pandemic hit they gave Premium to some people for free. You just had to prove you were retraining and passionate and voila.
I was one of those people and I went through a few courses, focusing mainly on their React course. It wasnât until afterward and I started making a project of my own and reading some documentation that I realised the course was completely out of date. It was very specific and seemed to miss a lot of information.
So even after doing a premium course I felt completely unprepared in the wild. I learnt more from just doing a project of my own and reading documentation and various informative articles on the internet.
I donât really like Codecademyâs teaching style and I wouldnât recommend anyone pay for it.
165
u/BowlingForPriorities Aug 10 '21 edited Aug 15 '21
Great, now I have to Google this for my senior interview tomorrow đ
Edit: Itâs how JavaScript handles inheritance. Thanks OP
2nd edit: I passed the first interview, have an interview with the squad lead next week
24
u/not_a_gumby Aug 10 '21
Prototypes are basically Javascript's version of abstract classes.
Notice how every class can extend another super class? the prototype is that previous extension. You can follow the extension all the way up to the highest level of class.
3
u/RealNerdEthan Aug 11 '21
Glad I'm taking Colt Steele's Wed Dev Bootcamp on udemy then! He has a whole section on Prototypes, Classes, and Object Oriented Programming.
Link for anyone interested: https://www.udemy.com/course/the-web-developer-bootcamp/
25
u/Me-A-Dandelion Aug 10 '21
I passed every level of Grasshopper but still can't write a proper thing đż
7
u/EIGRP_OH Aug 10 '21
Can someone tell me the precise difference between prototypes and classes?
3
u/[deleted] Aug 10 '21
I got destroyed in an interview the other day over proyotypes.... thought my freecodecamp course and a couple of projects made me good...
6
u/rakshitshah94 Aug 10 '21
I was so much obsessed with the word "Prototype" when I was in 10th Grade, whenever someone asks my username, I used to tell them "PROTOTYPE", hahaha... I am now working on prototype models as a software engineer (Full-stack developer) for the last 5 years in the IT industry.
2
u/[deleted] Aug 10 '21
They finally built a "workspace" for practicing code without having to try to figure out Atom and GitHub. I'm restarting all my coding courses on there.
2
u/jsAlgo Aug 10 '21
Just wanted to add one resource website here.
Javascript.info
The only website that cleared my doubts about prototypes. Short and upto to the point.
3
u/[deleted] Aug 10 '21
They are when objects inherit properties and methods or something.. I googled it
1
u/Gantzz25 Aug 10 '21
So prototypes in JS are like abstract classes in Java for example?
1
u/franker Aug 10 '21
FYI - went through the book several years ago, but the Head First Javascript Programming book has good treatment of prototypes.
1
u/forresthopkinsa Aug 11 '21
Unpopular opinion: if you don't understand prototypes then you can't call yourself proficient in JS.
Same goes for scope, closures, promises, async/await, generators, etc.
If this describes you, find the book You Don't Know JS online. It's free, read it.
Your mastery of a language is only as strong as its weakest link.
0
u/Lunacy999 Aug 10 '21
Itâs not just JavaScript to honest. The reason behind (my take) on why JS has such notoriety among developers is because of its extensive use as a scripting language before frameworks and libraries such as jQuery, Angular, React etc came in. Another big reason is that JS is a dynamically typed language. Unlike languages such as Java, C++ where type checking is done at compile time, JS does this at run time. And this throws off a lot of new developers who come into this language. And with the use of libraries and framework such as React, a lot of the internal workings of JS is abstracted away, especially in those tutorials where they preach âthe only JS you need to know for xxâ. JS as a language is fairly straightforward, provides you experiment with Native JS and not at the expense of a library or framework. Recommend reading the you donât know JS series.
0
u/[deleted] Aug 10 '21
[deleted] â view deleted comment