Brush Up On Your Fundamentals
Read Also: System Design Interview Prep
What Is The Need Of Tree Shaking
Tree Shaking can significantly reduce the code size in any application. i.e, The less code we send over the wire the more performant the application will be. For example, if we just want to create a Hello World Application using SPA frameworks then it will take around a few MBs, but by tree shaking it can bring down the size to just a few hundred KBs. Tree shaking is implemented in Rollup and Webpack bundlers.
What Will Consolelog Consolelog Return
For the first statement, it is true that one is less than two and two is less than one. Makes sense, right?
However, one is definitely not more than one, making the entire statement false.
Also Check: Interview With Cfo
The main benefit of using strict mode is catching errors early and making debugging your code easier. Common errors such as assigning a value to an undeclared variable would throw an error in strict mode alerting you that there is something wrong in your code.
You need to add the string use strict above the file to enable strict mode for that file.
Differences Between Declaring Variables Using Var Let And Const
Lets understand the differences with examples:
var variable1 =23 let variable2 =89 function catchValueswindow.variable1 // Returns the value 23window.variable2 // Returns undefined
var vs let in functional scope
function varVsLetFunctionconsole.log // Throws an errorconsole.log // Throws an error
console.log // Outputs console.log // Throws errorforconsole.log // Throws errorforconsole.log // Outputs 2
var var let Const keyword const any variable declared with the const keyword cannot be reassigned.
const x = x = // Throws an errorx.name ="Nikhil" // No error is thrownconst y =23 y =44 // Throws an error
Recommended Reading: Prepare For System Design Interview
A prompt box is a box which allows the user to enter input by providing a text box. The prompt method displays a dialog box that prompts the visitor for input. A prompt box is often used if you want the user to input a value before entering a page. When a prompt box pops up, the user will have to click either OK or Cancel to proceed after entering an input value.
How Do You Declare Strict Mode
The strict mode is declared by adding “use strict” to the beginning of a script or a function.If declared at the beginning of a script, it has global scope.
"use strict" x=3.14 // This will cause an error because x is not declared
and if you declare inside a function, it has local scope
x=3.14 // This will not cause an error.myFunction functionmyFunction
Read Also: Preparing For System Design Interview
What Are The Properties Used To Get Size Of Window
You can use innerWidth, innerHeight, clientWidth, clientHeight properties of windows, document element and document body objects to find the size of a window. Let’s use them combination of these properties to calculate the size of a window or document,
What Is The Prototype Design Pattern
The Prototype Design Pattern, also known as Properties Pattern is a creational design pattern based on prototypal inheritance. When an object is created, it acts as a prototype for other objects. You can think of the prototype object as a blueprint for other objects the constructor creates the properties defined in the prototype object will also be present in the cloned object it creates.
The prototype model is mainly used for creating objects in performance-intensive situations. The prototype pattern helps eliminate the overhead of initializing an object.
Common applications of the prototype pattern are when you have a system independent of how its contents are created or when creating objects from a database whose values are copied to the newly created object.
Don’t Miss: Design Interview Preparation
5. Can you differentiate between let and var?
- \b Backspace
- \t Horizontal tabulator
- \v Vertical tabulator
What Is The Purpose Of The Array Splice Method
The splice method is used either adds/removes items to/from an array, and then returns the removed item. The first argument specifies the array position for insertion or deletion whereas the optional second argument indicates the number of elements to be deleted. Each additional argument is added to the array.
Some of the examples of this method are,
letarrayIntegersOriginal1= letarrayIntegersOriginal2= letarrayIntegersOriginal3= letarrayIntegers1=arrayIntegersOriginal1.splice // returns original array: letarrayIntegers2=arrayIntegersOriginal2.splice // returns original array: letarrayIntegers3=arrayIntegersOriginal3.splice //returns original array:
Note: Splice method modifies the original array and returns the deleted array.
You May Like: Mailscoop Io
What Are The Pros And Cons Of Promises Over Callbacks
Below are the list of pros and cons of promises over callbacks,
Strict mode is a way to introduce better error-checking into your code.
- When you use strict mode, you cannot use implicitly declared variables, or assign a value to a read-only property, or add a property to an object that is not extensible.
- You can enable strict mode by adding use strict at the beginning of a file, a program, or a function.
Read Also: Interview Attire Womens
Q46 What Will Be The Output Of The Following Code
var X = var Output = ) console.log
The output would be undefined. The delete operator is used to delete the property of an object. Here, x is an object which has the property foo, and as it is a self-invoking function, we will delete the foo property from object x. After doing so, when we try to reference a deleted property foo, the result is undefined.
How Do You Print The Contents Of Web Page
The window object provided a print method which is used to print the contents of the current window. It opens a Print dialog box which lets you choose between various printing options. Let’s see the usage of print method in an example,
< inputtype="button" value="Print" onclick="window.print" />
Note: In most browsers, it will block while the print dialog is open.
You May Like: Questions To Ask A Cfo During An Interview
Thoroughly Understand The Tech Stack On Your Resume
Not all technical interviews will be on algorithms, many times the interviewer wants to be sure that youre a competent coder and youll need to build out a part of an application. For example, if you list that you know React on your resume, you better know how to build a component and understand how to use React hooks.
Come to the interview prepared to answer questions about the programming language or framework. Also make sure to use the correct terminology for terms and concepts.
Can I Redeclare Let And Const Variables
No, you cannot redeclare let and const variables. If you do, it throws below error
Uncaught SyntaxError: Identifier 'someVariable' has already been declared
Explanation: The variable declaration with var keyword refers to a function scope and the variable is treated as if it were declared at the top of the enclosing scope due to hoisting feature. So all the multiple declarations contributing to the same hoisted variable without any error. Let’s take an example of re-declaring variables in the same scope for both var and let/const variables.
varname="John" functionmyFuncmyFunc alert // John
The block-scoped multi-declaration throws syntax error,
letname="John" functionmyFuncmyFunc alert
You May Like: Best System Design Interview Prep
What Is The Purpose Of The Array Slice Method
The slice method returns the selected elements in an array as a new array object. It selects the elements starting at the given start argument, and ends at the given optional end argument without including the last element. If you omit the second argument then it selects till the end.
Some of the examples of this method are,
letarrayIntegers= letarrayIntegers1=arrayIntegers.slice // returns letarrayIntegers2=arrayIntegers.slice // returns letarrayIntegers3=arrayIntegers.slice //returns
Note: Slice method won’t mutate the original array but it returns the subset as a new array.
What Are Default Values In Destructuring Assignment
A variable can be assigned a default value when the value unpacked from the array or object is undefined during destructuring assignment. It helps to avoid setting default values separately for each assignment. Let’s take an example for both arrays and object use cases,
varx,y,z = console.log // 10console.log // 4console.log // 6
You May Like: Questions To Ask The Cfo In An Interview
Also Check: Interview Questions For A Cfo
This file exports two functions that calculate the squares and diagonal of the input respectively.
import from “calc”
console.log) // 16
console.log) // 5
Therefore, here we import those functions and pass input to those functions to calculate square and diagonal.
What Is An Observable
An Observable is basically a function that can return a stream of values either synchronously or asynchronously to an observer over time. The consumer can get the value by calling subscribe method.Let’s look at a simple example of an Observable
importfrom"rxjs" constobservable=newObservable=> ,3000) }) observable.subscribe=> console.log)
You May Like: Women’s Outfit For Job Interview
Have Your Elevator Pitch Down Pat
During the first few minutes of the interview youll have the opportunity to get to know your interviewer and exchange pleasantries. Theyre going to ask you about yourself and you should have a polished and well-versed response. Beyond just testing your technical skills, theyll want to get an overall feel of your personality.
This is your opportunity to build a rapport with the interviewer and possibly find something in common. Once you have some kind of rapport, itll automatically make you feel more at ease.
Don’t Miss: Cfo Interview
Explain The Difference Between Objectfreeze Vs Const
This explains your flexibility detailed understanding when it comes to handling variables and functions.
< em> const < span> human< /span> = < span> human< /span> = animal // ERROR < span> “person”< /span> is read-only< /em>
Object.freeze works on object values. It makes an object immutable, which means changing its properties is not possible.
< span> < em> let< /em> < /span> < em> human = Object.freeze human.name = < span> “Rohan”< /span> //TypeError: Cannot assign < span> to< /span> read < span> only< /span> property < span> ‘name'< /span> < span> of< /span> objectconsole.log < /em>
- Syntax errors Errors that occur at interpretation time such as during the loading of a web page due to incorrect syntax in the code.
- Runtime errors Errors that occur during the runtime of the program after it is interpreted by the compiler. Calling functions that dont exist is a common cause of this type of error.
- Logical Errors Errors caused by the codes logic itself. They are syntactically correct and dont necessarily cause runtime errors. To think of this in terms of a sentence in the English language the vocabulary and grammar of the sentence are correct, however, the meaning of the sentence is incorrect.
Don’t Miss: Interview Attire Women