Sign Up using. Log In using.
Work fast with our official CLI. Learn more. If nothing happens, download GitHub Desktop and try again.
Work fast with our official CLI. Learn more. If nothing happens, download GitHub Desktop and try again. If nothing happens, download Xcode and try again.
If nothing happens, download the GitHub extension for Visual Studio and try again. Pull Requests are highly appreciated. Follow me SudheerJonna for technical updates. You can download the PDF and Epub version of this repository from the latest run on the actions tab. The questions provided in this repository are the summary of frequently asked questions across numerous companies. We cannot guarantee that these questions will actually be asked during your interview process, nor should you focus on memorizing all of them.
The simplest way to create an empty object is using the Object constructor. Currently this approach is not recommended. This is equivalent to an instance created with an object create method with a function prototype and then call that function with an instance and parameters as arguments.
A Singleton is an object which can only be instantiated one time. Repeated calls to its constructor return the same instance and this way one can ensure that they don't accidentally create multiple instances.
Prototype chaining is used to build new types of objects based on existing ones. It is similar to inheritance in a class based language. The prototype on object instance is available through Object. Call: The call method invokes a function with a given this value and arguments provided one by one. Call and apply are pretty interchangeable. Both execute the current function immediately. You can remember by treating Call is for comma separated list and Apply is for Array.
Whereas Bind creates a new function that will have this set to the first parameter passed to bind. It is useful when you want to transmit data across a network and it is basically just a text file with an extension of. 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,. Note: Slice method won't mutate the original array but it returns the subset as a new array. The first argument specifies the array position for insertion or deletion whereas the option second argument indicates the number of elements to be deleted.
Each additional argument is added to the array. Objects are similar to Maps in that both let you set keys to values, retrieve those values, delete keys, and detect whether something is stored at a key. Due to this reason, Objects have been used as Maps historically. But there are important differences that make using a Map preferable in certain cases.
The strict operators follow the below conditions for different types,. An arrow function is a shorter syntax for a function expression and does not have its own this, arguments, super, or new. These functions are best suited for non-method functions, and they cannot be used as constructors.
Higher-order function is a function that accepts another function as an argument or returns a function as a return value. Unary function i. Let us take an example of unary function. It stands for a single argument accepted by a function. Currying is the process of taking a function with multiple arguments and turning it into a sequence of functions each with only a single argument.
Currying is named after a mathematician Haskell Curry. By applying currying, a n-ary function turns it into a unary function. Let's take an example of n-ary function and how it turns into a currying function. A Pure function is a function where the return value is only determined by its arguments without any side effects.
Let's take an example to see the difference between pure and impure functions,. As per above code snippets, Push function is impure itself by altering the array and returning an push number index which is independent of parameter value.
Whereas Concat on the other hand takes the array and concatenates it with the other array producing a whole new array without side effects. Also, the return value is a concatenation of the previous array. Remember that Pure functions are important as they simplify unit testing without any side effects and no need for dependency injection.
They also avoid tight coupling and make it harder to break your application by not having any side effects. These principles are coming together with Immutability concept of ES6 by giving preference to const over let usage. The let statement declares a block scope local variable. Hence the variables defined with let keyword are limited in scope to the block, statement, or expression on which it is used. Whereas variables declared with the var keyword used to define a variable globally, or locally to an entire function regardless of block scope.
Let's take an example to demonstrate the usage,. Let is a mathematical statement that was adopted by early programming languages like Scheme and Basic. It has been borrowed from dozens of other languages that use let already as a traditional keyword as close to var as possible. If you try to redeclare variables in a switch block then it will cause errors because there is only one block.
Service worker can't access the DOM directly. But it can communicate with the pages it controls by responding to messages sent via the postMessage interface, and those pages can manipulate the DOM. The problem with service worker is that it gets terminated when not in use, and restarted when it's next needed, so you cannot rely on global state within a service worker's onfetch and onmessage handlers.
This API uses indexes to enable high-performance searches of this data. The web storage provides two mechanisms for storing data on the client. Post message is a method that enables cross-origin communication between Window objects. Generally, scripts on different pages are allowed to access each other if and only if the pages follow same-origin policy i. A cookie is a piece of data that is stored on your computer to be accessed by your browser.
For example, you can create a cookie named username as below,. Cookies are used to remember information about the user profile such as username. It basically involves two steps,. You can delete a cookie by setting the expiry date as a passed date.
You don't need to specify a cookie value in this case.