By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Q1. Explain equality in JavaScript.
JavaScript has both strict and type- converting comparisons:
Strict comparison (e.g., ===) checks for value equality without allowing coercion Abstract comparison (e.g. ==) checks for value equality with coercion allowed
var a = "42"; var b = 42;
a == b; // true a === b; // false
Some simple equality rules:
If either value (aka side) in a comparison could be the true or false value, avoid == and use ===. If either value in a comparison could be of these specific values (0, "", or [] -- empty array), avoid == and use ===. In all other cases, you're safe to use ==. Not only is it safe, but in many cases it simplifies your code in a way that improves readability.
Q 2. What is Reactive Programming? Reactive programming is programming with asynchronous data streams. Event buses or your typical click events are really an asynchronous event stream, on which you can observe and do some side effects. With Reactive programming, you are able to create data streams of anything, not just from click and hover events. Streams are cheap and ubiquitous, anything can be a stream: variables, user inputs, properties, caches, data structures, etc. For example, imagine your Twitter feed would be a data stream in the same fashion that click events are. You can listen to that stream and react accordingly.
Q 3. What is Scope in JavaScript?
In JavaScript, each function gets its own scope. Scope is basically a collection of variables as well as the rules for how those variables are accessed by name. Only code inside that function can access that function's scoped variables.
A variable name has to be unique within the same scope. A scope can be nested inside another scope. If one scope is nested inside another, code inside the innermost scope can access variables from either scope.
Q 4. What is blockchain?
Blockchain is a secure distributed ledger (data structure or database) that maintains a continuously growing list of ordered records, called 'blocks', that are linked using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data.
By design, a blockchain is resistant to modification of the data. It is "an open, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way".
Once recorded, the data in any given block cannot be altered retroactively without alteration of all subsequent blocks, which requires consensus of the network majority.
Q 5. What is meant by Continuous Integration?
Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.
Q 6. What is npm? npm stands for Node Package Manager. npm provides following two main functionalities:
Online repositories for node.js packages/modules which are searchable on search.nodejs.org Command line utility to install packages, do version management and dependency management of Node.js packages.
Q 7. What is the purpose of the alt attribute on images? The alt attribute provides alternative information for an image if a user cannot view it. The alt attribute should be used to describe any images except those which only serve a decorative purposes, in which case it should be left empty.
Q 8. What is webpack?
Webpack is a build tool that puts all of your assets, including Javascript, images, fonts, and CSS, in a dependency graph. Webpack lets you use require() in your source code to point to local files, like images, and decide how they're processed in your final Javascript bundle, like replacing the path with a URL pointing to a CDN.
Q 9. Explain Null and Undefined in JavaScript
JavaScript (and by extension TypeScript) has two bottom types: null and undefined. They are intended to mean different things:
Something hasn't been initialised : undefined. Something is currently unavailable: null.
Q 10. How can I prevent XSS?
XSS can be prevented by sanitizing user input to the application. Always allowed those elements as input which is absolutely essential for that field.
Q 11. Implement enqueue and dequeue using only two stacks
Enqueue means to add an element, dequeue to remove an element.
var inputStack = []; // First stack var outputStack = []; // Second stack
// For enqueue, just push the item into the first stack function enqueue(stackInput, item) { return stackInput.push(item); }
function dequeue(stackInput, stackOutput) { // Reverse the stack such that the first element of the output stack is the // last element of the input stack. After that, pop the top of the output to // get the first element that was ever pushed into the input stack if (stackOutput.length <= 0) { while(stackInput.length > 0) { var elementToOutput = stackInput.pop(); stackOutput.push(elementToOutput); } }
return stackOutput.pop(); }
Q 12. What are different HTTP Methods supported in Restful Web Services?
Restful web services supported HTTP methods are:
GET, POST, PUT, DELETE and HEAD.
Q 13. What does Containerization mean?
Containerisation is a type of virtualization strategy that emerged as an alternative to traditional hypervisor-based virtualization.
In containerization, the operating system is shared by the different containers rather than cloned for each virtual machine. For example Docker provides a container virtualization platform that serves as a good alternative to hypervisor-based arrangements.
Q 14. What does use strict do?
The use strict literal is entered at the top of a JavaScript program or at the top of a function and it helps you write safer JavaScript code by throwing an error if a global variable is created by mistake. For example, the following program will throw an error:
function doSomething(val) { "use strict"; x = val + 10; }`
It will throw an error because x was not defined and it is being set to some value in the global scope, which isn't allowed with use strict The small change below fixes the error being thrown:
function doSomething(val) { "use strict"; var x = val + 10; }
Q 15. What is CORS and how to enable one?
A request for a resource (like an image or a font) outside of the origin is known as a cross-origin request. CORS (cross-origin resource sharing) manages cross-origin requests. CORS allows servers to specify who (i.e., which origins) can access the assets on the server, among many other things.
Access-Control-Allow-Origin is an HTTP header that defines which foreign origins are allowed to access the content of pages on your domain via scripts using methods such as XMLHttpRequest.
For example, if your server provides both a website and an API intended for XMLHttpRequest access on a remote websites, only the API resources should return the Access-Control-Allow-Origin header. Failure to do so will allow foreign origins to read the contents of any page on your origin.
# Allow any site to read the contents of this JavaScript library, so that subresource integrity works Access-Control-Allow-Origin: *
Q 16. What is Cross Site Scripting (XSS)?
By using Cross Site Scripting (XSS) technique, users executed malicious scripts (also called payloads) unintentionally by clicking on untrusted links and hence, these scripts pass cookies information to attackers.
Q 17. What is DOM (Document Object Model) and how is it linked to CSS?
The Document Object Model (DOM) is a cross-platform and language-independent application programming interface that treats an HTML, XHTML, or XML document as a tree structure wherein each node is an object representing a part of the document.
With the Document Object Model, programmers can create and build documents, navigate their structure, and add, modify, or delete elements and content. The DOM specifies interfaces which may be used to manage XML or HTML documents.
When a browser displays a document, it must combine the document's content with its style information. The browser converts HTML and CSS into the DOM (Document Object Model). The DOM represents the document in the computer's memory. It combines the document's content with its style.
Q 18. What is Sprint Planning? The work to be performed in the Sprint is planned at the Sprint Planning. This plan is created by the collaborative work of the entire Scrum Team.
Sprint Planning answers the following:
What can be delivered in the Increment resulting from the upcoming Sprint? How will the work needed to deliver the Increment be achieved? The Sprint Goal is an objective set for the Sprint that can be met through the implementation of Product Backlog.
Q 19. What is Test Driven Development?
Test Driven Development (TDD) is also known as test-driven design. In this method, the web developer:
first writes an automated test case which describes new function or improvement and then creates small codes to pass that test, and later re-factors the new code to meet the acceptable standards.
Q 20. What is the difference between procedural and object-oriented programming?
Procedural programming is based upon the modular approach in which the larger programs are broken into procedures. Each procedure is a set of instructions that are executed one after another. On the other hand, OOP is based upon objects. An object consists of various elements, such as methods and variables.
Access modifiers are not used in procedural programming, which implies that the entire data can be accessed freely anywhere in the program. In OOP, you can specify the scope of a particular data by using access modifiers - public, private, internal, protected, and protected internal.
Q 21. What is the difference between span and div?
div is a block element span is inline element For bonus points, you could point out that it's illegal to place a block element inside an inline element, and that while div can have a p tag, and a p tag can have a span, it is not possible for span to have a div or p tag inside.
Q 22. Could you explain the difference between ES5 and ES6
ECMAScript 5 (ES5): The 5th edition of ECMAScript, standardized in 2009. This standard has been implemented fairly completely in all modern browsers
ECMAScript 6 (ES6)/ ECMAScript 2015 (ES2015): The 6th edition of ECMAScript, standardized in 2015. This standard has been partially implemented in most modern browsers.
Here are some key differences between ES5 and ES6:
Arrow functions & string interpolation: Consider: const greetings = (name) => { return `hello ${name}`; } and even:
const greetings = name => `hello ${name}`;
Const. Const works like a constant in other languages in many ways but there are some caveats. Const stands for 'constant reference' to a value. So with const, you can actually mutate the properties of an object being referenced by the variable. You just can't change the reference itself. const NAMES = []; NAMES.push("Jim"); console.log(NAMES.length === 1); // true NAMES = ["Steve", "John"]; // error
Block-scoped variables. The new ES6 keyword let allows developers to scope variables at the block level. Let doesn't hoist in the same way var does. Default parameter values Default parameters allow us to initialize functions with default values. A default is used when an argument is either omitted or undefined - meaning null is a valid value.
// Basic syntax function multiply (a, b = 2) { return a * b; } multiply(5); // 10
Class Definition and Inheritance ES6 introduces language support for classes (class keyword), constructors (constructor keyword), and the extend keyword for inheritance.
for-of operator The for...of statement creates a loop iterating over iterable objects.
Spread Operator For objects merging const obj1 = { a: 1, b: 2 } const obj2 = { a: 2, c: 3, d: 4} const obj3 = {...obj1, ...obj2}
Promises Promises provide a mechanism to handle the results and errors from asynchronous operations. You can accomplish the same thing with callbacks, but promises provide improved readability via method chaining and succinct error handling. const isGreater = (a, b) => { return new Promise ((resolve, reject) => { if(a > b) { resolve(true) } else { reject(false) } }) } isGreater(1, 2) .then(result => { console.log('greater') }) .catch(result => { console.log('smaller') }) Modules exporting & importing Consider module exporting: const myModule = { x: 1, y: () => { console.log('This is ES5') }} export default myModule; and importing:
import myModule from './myModule';
Q 23. Explain almost standard, full standard and quirks mode
There are now three modes used by the layout engines in web browsers: quirks mode, almost standards mode, and full standards mode.
In quirks mode, layout emulates nonstandard behavior in Navigator 4 and Internet Explorer 5. This is essential in order to support websites that were built before the widespread adoption of web standards. In full standards mode, the behavior is (hopefully) the behavior described by the HTML and CSS specifications. In almost standards mode, there are only a very small number of quirks implemented. For HTML documents, browsers use a DOCTYPE in the beginning of the document to decide whether to handle it in quirks mode or standards mode.
Q 24. Explain the difference between Object.freeze() vs const
const and Object.freeze are two completely different things.
const applies to bindings ("variables"). It creates an immutable binding, i.e. you cannot assign a new value to the binding. const person = { name: "Leonardo" }; let animal = { species: "snake" }; person = animal; // ERROR "person" is read-only Object.freeze works on values, and more specifically, object values. It makes an object immutable, i.e. you cannot change its properties. let person = { name: "Leonardo" }; let animal = { species: "snake" }; Object.freeze(person); person.name = "Lima"; //TypeError: Cannot assign to read only property 'name' of object console.log(person);
Q 25. Given two strings, return true if they are anagrams of one another
For example: Mary is an anagram of Army
var firstWord = "Mary"; var secondWord = "Army";
isAnagram(firstWord, secondWord); // true
function isAnagram(first, second) { // For case insensitivity, change both words to lowercase. var a = first.toLowerCase(); var b = second.toLowerCase();
// Sort the strings, and join the resulting array to a string. Compare the results a = a.split("").sort().join(""); b = b.split("").sort().join("");
return a === b; }
Q 26. How is responsive design different from adaptive design?
Both responsive and adaptive design attempt to optimize the user experience across different devices, adjusting for different viewport sizes, resolutions, usage contexts, control mechanisms, and so on.
Responsive design works on the principle of flexibility - a single fluid website that can look good on any device. Responsive websites use media queries, flexible grids, and responsive images to create a user experience that flexes and changes based on a multitude of factors. Like a single ball growing or shrinking to fit through several different hoops.
Adaptive design is more like the modern definition of progressive enhancement. Instead of one flexible design, adaptive design detects the device and other features, and then provides the appropriate feature and layout based on a predefined set of viewport sizes and other characteristics. The site detects the type of device used, and delivers the pre-set layout for that device. Instead of a single ball going through several different-sized hoops, you'd have several different balls to use depending on the hoop size.
Q 27. How to compare two objects in JavaScript?
Two non-primitive values, like objects (including function and array) held by reference, so both == and === comparisons will simply check whether the references match, not anything about the underlying values.
For example, arrays are by default coerced to strings by simply joining all the values with commas (,) in between. So two arrays with the same contents would not be == equal:
var a = [1,2,3]; var b = [1,2,3]; var c = "1,2,3";
a == c; // true b == c; // true a == b; // false For deep object comparison use external libs like deep-equal or implement your own recursive equality algorithm.
Q 28. How would you choose between SOAP and REST web services?
Web Services work on client-server model and when it comes to choose between SOAP and REST, it all depends on project requirements.
Do you know your web service clients beforehand? If Yes, then you can define a contract before implementation and SOAP seems better choice. But if you don't then REST seems better choice because you can provide sample request/response and test cases easily for client applications to use later on. For quick implementation REST is the best choice. You can create web service easily, test it through browser/curl and get ready for your clients. What kind of data format are supported? If only XML then you can go with SOAP but if you think about supporting JSON also in future then go with REST.
Q 29. State the features of an interface.
An interface is a template that contains only the signature of methods. The signature of a method consists of the numbers of parameters, the type of parameter (value, reference, or output), and the order of parameters. An interface has no implementation on its own because it contains only the definition of methods without any method body. An interface is defined using the interface keyword. Moreover, you cannot instantiate an interface. The various features of an interface are as follows:
An interface is used to implement multiple inheritance in code. This feature of an interface is quite different from that of abstract classes because a class cannot derive the features of more than one class but can easily implement multiple interfaces.
It defines a specific set of methods and their arguments. Variables in interface must be declared as public, static, and final while methods must be public and abstract. A class implementing an interface must implement all of its methods. An interface can derive from more than one interface. Having Tech or Coding Interview? Check 👉 54 OOP Interview Questions
Q 30. What are the DRY and DIE principles? In software engineering, Don't Repeat Yourself (DRY) or Duplication is Evil (DIE) is a principle of software development.
Q 31. What are the advantages and disadvantages of using use strict? 'use strict' is a statement used to enable strict mode to entire scripts or individual functions. Strict mode is a way to opt into a restricted variant of JavaScript.
Advantages:
Makes it impossible to accidentally create global variables. Makes assignments which would otherwise silently fail to throw an exception. Makes attempts to delete undeletable properties throw (where before the attempt would simply have no effect). Requires that function parameter names be unique. this is undefined in the global context. It catches some common coding bloopers, throwing exceptions. It disables features that are confusing or poorly thought out.
Disadvantages:
Many missing features that some developers might be used to. No more access to function.caller and function.arguments. Concatenation of scripts written in different strict modes might cause issues. Overall, I think the benefits outweigh the disadvantages, and I never had to rely on the features that strict mode blocks. I would recommend using strict mode.
Q 32. What are the best practices for caching?
Always keep static contents like images, css, JavaScript cacheable, with expiration date of 2 to 3 days. Never keep expiry date too high.
Dynamic contents should be cached for few hours only.
Q 33. What are the features of Microservices?
Decoupling - Services within a system are largely decoupled. So the application as a whole can be easily built, altered, and scaled Componentization - Microservices are treated as independent components that can be easily replaced and upgraded Business Capabilities - Microservices are very simple and focus on a single capability Autonomy - Developers and teams can work independently of each other, thus increasing speed Continous Delivery - Allows frequent releases of software, through systematic automation of software creation, testing, and approval Responsibility - Microservices do not focus on applications as projects. Instead, they treat applications as products for which they are responsible Decentralized Governance - The focus is on using the right tool for the right job. That means there is no standardized pattern or any technology pattern. Developers have the freedom to choose the best useful tools to solve their problems Agility - Microservices support agile development. Any new feature can be quickly developed and discarded again
Q 34. What is CSS selectors? Name some.
A CSS selector is the part of a CSS rule set that actually selects the content you want to style.
Consider some types of CSS selectors:
Universal selector: * Element type selector: ul, td ID Selector: #id Class selector: .box Descendant combinator: #id .box. The .box element doesn't have to be an immediate child of #id. Child combinator: #id > .box. Unlike the descendant combinator, there can't be another element wrapping .box General Sibling Combinator: ~ Adjacent Sibling Combinator: +. The difference from general sibling combinaltor is that the targeted element must be an immediate sibling, not just a general sibling. Attribute Selector: input[type="text"] Pseudo-class: a:hover. A pseudo-class uses a colon character to identify a pseudo-state that an element might be in. Pseudo-element: .container::before. This selector inserts an imaginary element into the page, inside the targeted element, before its contents.
Q 35. What is Coercion in JavaScript?
In JavaScript conversion between different two build-in types called coercion. Coercion comes in two forms in JavaScript: explicit and implicit.
Here's an example of explicit coercion:
var a = "42";
var b = Number( a );
a; // "42" b; // 42 -- the number!
And here's an example of implicit coercion:
var b = a * 1; // "42" implicitly coerced to 42 here
Q 36. What is HTML5 Web Storage? Explain localStorage and sessionStorage.
With HTML5, web pages can store data locally within the user's browser. The data is stored in name/value pairs, and a web page can only access data stored by itself.
Differences between localStorage and sessionStorage regarding lifetime:
Data stored through localStorage is permanent: it does not expire and remains stored on the user's computer until a web app deletes it or the user asks the browser to delete it. sessionStorage has the same lifetime as the top-level window or browser tab in which the data got stored. When the tab is permanently closed, any data stored through sessionStorage is deleted.
Differences between localStorage and sessionStorage regarding storage scope:
Both forms of storage are scoped to the document origin so that documents with different origins will never share the stored objects.
sessionStorage is also scoped on a per-window basis. Two browser tabs with documents from the same origin have separate sessionStorage data. Unlike in localStorage, the same scripts from the same origin can't access each other's sessionStorage when opened in different tabs.
Q 37. What is IIFEs (Immediately Invoked Function Expressions)?
It's an Immediately-Invoked Function Expression, or IIFE for short. It executes immediately after it's created:
(function IIFE(){ console.log( "Hello!" ); })(); // "Hello!"
This pattern is often used when trying to avoid polluting the global namespace, because all the variables used inside the IIFE (like in any other normal function) are not visible outside its scope.
Some unanswered questions:
Q 38: Explain difference between: function Person(){}, var person = Person(), and var person = new Person()?
Q 39: How does the this keyword work? Provide some code examples
Q 40: What is GOD class and why should we avoid it?
Q 41: What is Hoisting in JavaScript?
Q 42: What is Closure in JavaScript? Provide an example
Q 43: What is progressive rendering?
Q 44: What is the difference between cohesion and coupling?
Q 45: What should be the purpose of OPTIONS method of RESTful web services?
Q 46: Write a recursive function that performs a binary search
Q 47: Describe tree shaking mechanism in webpack
Q 48: What does it mean to 'program to an interface'?
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.