A Few Common JavaScript Questions Seen in Interviews

Kevin Peery
5 min readMay 27, 2019

--

Over the past few months, I was invited to several interviews for potential JavaScript software engineering roles. I took note of the concepts and topics on which I was being quizzed since I observed the same questions reappearing. Below I will discuss a few of the topics I was asked to demonstrate knowledge of. Many of those topics were explicitly covered during the software engineering immersive programs which I attended at both the Flatiron School and through the Full-Time Web Development Program at the University of Utah in Salt Lake City, Utah. I was fortunate to have won two scholarships at around the same time to attend each of those programs and structured my progression through the programs such that I was able to complete both of them and maximize the learning benefit of each experience. Each program offered its own unique strengths relevant to the software engineering field. Both focused on teaching the key competencies and skill sets sought by companies seeking tech talent. Since both programs covered a similar technology stack, by attending two programs rather than only one, the concepts learned were further reinforced and my understanding was solidified through repetition and practice. Therefore, I created a robust GitHub account that focuses on apps coded in Ruby, Ruby on Rails, SQL, PostgreSQL, MySQL, MongoDB, JavaScript, Node.js, Express.js, React, Redux and more.

My Certificate from the University of Utah
My Certificate from Flatiron School

Describe the main principles of Object Oriented Programming (OOP)

Object-oriented programming is a popular programming paradigm centered around objects rather than functions. The main principles of object-oriented programming as they relate to JavaScript are encapsulation, abstraction, inheritance, and polymorphism. Polymorphism, fits better with static-typed programming languages such as C, C++, C#, Java, Go, Haskell, Kotlin, Swift, Scala, and others within the same category. Object-oriented programming allows us to program in a way that is more natural and closer to reality by using classes, objects, methods, properties, and so on.

Object: In Javascript (JS), the object is the centerpiece and everything is an object. This means that Objects in JS are much like objects in real life, much like a car is an object. They have properties and things they can do, which are called methods. For example, a car has properties such as its color, model, year built, etc… It also has things it can do (JS methods) such as drive, reverse, turn, accelerate, etc…Objects in real life, such as cars, planes, and trains, have properties and things they can do. The same holds true with JS objects.

Encapsulation is the process of combining data and functions into a single unit called a class. Public functions, which can be accessed, are called methods. In Encapsulation, the data, or state, is not accessed directly. Rather, it is accessed through those public methods (functions) which are present inside of the class. This serves to hide the internal representation, or state, of an object from the outside. By hiding specific information and controlling access to the object’s internal state you achieve what is known as information hiding. More simply, attributes of the class are kept private, while public methods work to manipulate and interact with those attributes. Encapsulation, therefore, makes the concept of data hiding possible.

Abstraction extends the idea of encapsulation described above. It is the process of abstracting away the data that should be hidden from the user. Thus, you are able to only show relevant data while away hiding unnecessary details of an object. For example, consider driving an automatic vehicle. You simply need to know how to turn the steering wheel and move the gears through the whole array of options from drive to reverse. You don’t have to know every detail about what is happening under the hood as you drive the car. You simply need to know how to drive it. The detailed mechanical processes of the car’s engine are abstracted away.

Abstraction and Encapsulation together help you maintain a large code base.

Inheritance allows software developers to inherit commonalities between different objects. This permits reuse of common logic while simultaneously extracting out particular logic into a separate class. It allows for the formation of a hierarchy by creating a child class through the process of deriving methods from a separate parent class. In doing this, the child class is able to recycle all fields and methods of its parent class while creating its own unique methods.

Polymorphism allows you to write a single function which can handle many data-types. It is very similar to the concept of abstraction described above. In Greek, polymorphism simply means “many shapes.” It allows a variable, function or object to take on many shapes or multiple forms. By taking advantage of the concept of inheritance, polymorphism allows software developers to design objects that share certain behaviors while also having the option of overriding those shared behaviors in favor of more specific ones.

More topics to come on recursion, stack, queue, and more.

Sources:

--

--

No responses yet