Skip to content

Instantly share code, notes, and snippets.

@delasy
Created September 30, 2024 11:53
Show Gist options
  • Save delasy/4112867b0261137f1f34d77d4b4f728c to your computer and use it in GitHub Desktop.
Save delasy/4112867b0261137f1f34d77d4b4f728c to your computer and use it in GitHub Desktop.
Interview Questions

Coding Interview Questions

React.js

What version of react you worked with?

What is React?

What is JSX?

What is the difference between Element and Component?

What are fragments?

How to apply validation on props in React?

What is state in React?

Examples how would you declare a state in React

Next.js

what is next.js and what you used it for?

how do you opt out of using cache in Next.js

How do you handle errors in a Next.js application?

How do you implement serverless functions in a Next.js application?

Difference dynamic segment and dynamic catch-all segments

what are middlewares in Nextjs

Strapi.js

purpose of Strapi how it can be used

how does frontend communicate with strapi backedn

what Strapi plugins you have experience with

when adding new feature to Strapi how do you make sure to have backward compatibility?

MongoDB

Explain what are indexes in MongoDB?

What is sharding in MongoDB?

How replication works in MongoDB?

JavaScript

What is the difference between == and === operators

What is a promise

What is a callback function

What is purpose of promise.all

How do you check if a key exists in an object var obj = { key2: "value" }

What is a polyfill

() => {} === () => {}

console.log([0, 1, 2, 3][2, 3])

What is the rest parameter and spread operator?

Explain Hoisting

Difference between “ == “ and “ === “ operators

Difference between var and let keyword

What are callbacks? Why do we use callbacks?

Is javascript a statically typed or a dynamically typed language?

What are arrow functions?

What is Object Destructuring?

Node.js

Is Node a single threaded runtime env?

If Node.js is single threaded then how it handles concurrency?-

How do you convert an existing callback API to promises?

PHP

what is the difference between variables and constants?

What is a session in PHP?

Is PHP a case-sensitive language?

What is the purpose of @ in PHP?

What are traits?

Traits are a mechanism that lets you create reusable code in PHP and similar languages where multiple inheritances are not supported. It’s not possible to instantiate it on its own. A trait is intended to reduce the limitations of single inheritance by enabling a developer to reuse sets of methods freely in many independent classes living in different hierarchies of class.

Vue.js

What exactly is Vue.js?

Vue.js is a framework for creating user interfaces that are built on JavaScript. It's a framework that's progressive. Vue.js is responsible for the view layer of an application. Vue.js may be used to create single-page applications. Vue is a framework that handles higher-level issues like fast DOM rendering, reactive state management, tools, client-side routing, and server-side rendering.

what is single page application

What is a single-file component?

A single-file component is a file with a .vue extension that contains a Vue component. It contains the component's template, logic, and styles all bundled together in one file. It consists of one <script> block, optional <template> and <style> blocks, and possible additional custom blocks. To use one, you need to set up Vue Loader for parsing the file (usually done as part of a webpack building pipeline). But this then also supports using non-default languages such as Sass or HTML templating languages with pluggable pre-processors.

Explain Vue.js reactivity and common issues when tracking changes

All properties defined in a Vue instance’s data option are reactive, meaning that if they change, the component is automatically updated and re-rendered as needed. All such properties are converted to getters and setters during initialization, thus allowing Vue to detect when those properties are accessed or changed. The following limitations must be accounted for when designing a Vue app:

  • Vue cannot detect object property addition or deletion due to a JavaScript limitation, so the Vue.set method must be used to add new root-level reactive properties.
  • Similarly, Vue cannot detect when an array item is modified using an index. Vue.set must be used here as well.

How does Vue know when it should rerender?

Vue uses an unobtrusive reactivity system which is one its most distinct features. But what is reactivity? Reactivity is a programming paradigm that allows us to adjust to changes in a declarative manner.

What is the difference between one-way data flow and two-way data binding?

We can pass data between components in the following ways-  Props: It is like an argument that is given to the component. The term used to define this is an attribute. This is registered on the component and it allows to pass of the data from the parent component to the child component. To pass data through props, we can define the prop on the child component, and then bind the data to the prop on the parent component. Vue uses a one-way data flow. Parents can pass data to child components using a prop and bind the data using the v-bind directive. When the parent component updates the prop value, it's automatically updated in the child component. You should avoid mutating the property inside the child component and it will not affect the property in the parent component (unless it's an array or object). Using Events the child component can communicate back to the parent. Vue provides the v-model directive for two-way data binding of form inputs. v-model is just syntax sugar for v-bind combined with v-on:input. But you can also implement v-model for your custom components, take a look at "Using v-model on Components" for more details.

Describe the lifecycle hooks in Vue.js?

Lifecycle hooks are functions that every Vue instance runs through. Each vue has eight lifecycle hooks. An instance of js

  • Before Create - This is the first lifecycle hook that is called when a Vue instance has been created.
  • Created - It's called immediately after the 'Before creates' hook, but the Vue instance has already set initial properties, data, etc.
  • Before mount - invoked right before the instance is mounted on the DOM. The template has been completed at this time.
  • Mounted - This is the name given to the template once it has been filled with data and is fully functional.
  • Before Updated - When any changes to data require the DOM to be changed, this method is called before the update.
  • Updated - It's called after the DOM has been updated.
  • Before destroy - It's a location where you can clean up your resources before terminating the Vue instance.
  • Destroyed - When all Vue instances have been destroyed, this method is called. When you call the destruct method on an object in code, it will be activated.

Mention some of the pre-built directives in Vue.js

v-for, v-show, v-if, v-else, v-bind, v-model, and so on are some of the inbuilt directives present in Vue.js. v-html

Describe the distinction between v-show and v-if?

The items are shown or hidden using v-show and v-if. However, there are some distinctions. The v-if directive is used to render a block conditionally. It features lazy behaviour, which means that if the initial condition is false, the block will not be rendered until it changes. During a condition change, v-if destroys and recreates the elements. When your condition does not frequently change at runtime, use the v-if directive because it has a lower initial render cost but a higher toggling cost. The v-show directive can also be used to render a block conditionally. The element is always rendered by v-show. Instead of removing the element or block from the DOM, it simply sets the CSS show attribute.
It has a high initial rendering cost but a low toggle cost, so use the v-show directive if you need to toggle frequently.

What is the use of the v-for directive in Vue.js?

v-for directive is basically an inbuilt directive, which is used to iterate over a particular array or an object

Which inbuilt directive in Vue.js is used to establish two-way bindings?

The v-model directive is used to create the two-way bindings in Vue.js.

Explain the difference between slots and scoped slots

A slot is a placeholder in a child component that is filled with content passed from the parent. Content of a regular slot is compiled in the parent’s scope and then passed to the child component. Thus you can’t use child component properties in a slot’s content. But scoped slots allow you to pass child component data to the parent scope and then use that data in slot content.

What is the use of $child property in Vue.js?

Similar to the $parent property, the $child property enables the developer to access the child instance.

What are $refs in Vue.js?

These are used to indicate a reference to other HTML elements or child elements.

What are computed properties?

Computed properties should be used to remove as much logic as possible from the templates as otherwise the template gets bloated and is harder to maintain. If you have complex logic including reactive data in your template you should use a computed property instead. Instead of methods, computed properties are cached based on their reactive dependencies. A computed property will only re-evaluate when some of its reactive dependencies have changed.

What are watchers?

Watchers are a more generic way to react to data changes instead of using computed properties. They should be used when asynchronous or expensive operations need to be executed in response to changing data.

What are mixins? Describe their benefits and drawbacks

Mixin support is a feature that allows code reuse between components in a Vue.js application and a software composition tool.

Nuxt.js

Explain the key differences between Nuxt.js and Vue.js

How does the server-side rendering work in Nuxt.js?

How does Nuxt.js handle routing, and how does this compare to the Vue Router?

How would you handle error pages in Nuxt.js?

Describe a situation where you need to use middleware in Nuxt.js and how you would implement it.

Explain how you would handle state management in a Nuxt.js application.

What are the different modes that Nuxt.js can be run in and why might you choose one over the other?

Nuxt.js operates in three modes: Universal, Single Page Application (SPA), and Static. Universal mode is server-side rendering (SSR) where the server pre-renders HTML files for each page. This improves SEO and initial page loading speed as users don’t have to wait for all JavaScript to be downloaded and executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment