
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9150 Articles for Object Oriented Programming

549 Views
The difference between 'throw new Error' and 'throw someObject' in javascript is that throw new Error wraps the error passed to it in the following format −{ name: 'Error', message: 'Whatever you pass in the constructor' }The throw someObject will throw the object as is and will not allow any further code execution from the try block, ie same as throw new Error.

3K+ Views
The replaceState() method replaces the current history entry with the state objects, title, and URL passed as method parameters. This method is useful when you want to update the current history entry's state object or URL in response to a user action. To remove the hash URL, use the history API's replaceState method to remove the hash location. Syntax The syntax for the replaceState() method is as follows − window.history.replaceState(stateObj, "unused", "url") The function will take three parameters. They are − stateObj − This parameter is associated with history entry which is passed to the replace method. This ... Read More

1K+ Views
Future is an old term that is same as promise.A promise represents a value that is not yet known. This can better be understood as a proxy for a value not necessarily known when the promise is created.A deferred represents work that is not yet finished. A deferred (which generally extends Promise) can resolve itself, while a promise might not be able to do so. This can also be thought of as a promise that'll always succeed only.A promise is a placeholder for a result which is initially unknown while a deferred represents the computation that results in the value.Read More

43K+ Views
In System Design, there are two types of approaches followed namely, the Bottom-Up Model and the Top-Down Model. The bottom-up model is one in which the different parts of a system are designed and developed and then all these parts are connected together as a single unit. On the other hand, the top-down model is one in which the whole system is decomposed into smaller sub-components, then each of these parts are designed and developed till the completed system is designed. Read this article to find out more about the bottom-up model and the top-down model of system ... Read More

8K+ Views
AssociationAssociation in terms of objects refers to "has a" relationship between two related objects. For example, a employee has a communication address.class Employee { String name; Address communicationAddress; } class Address { String address; }AggregationAggregation in terms of objects refers to "has a"+ relationship between two related objects. For example, a department has multiple employees. It refers to having a collection of child objects in parent class. For example:class Department { String name; List employees; } class Employee { String name; }Sr. No.KeyAssociationAggregation1DefinitionAssociation refers to "has a" relationship between two classes which use each ... Read More

98 Views
There is no solid reason to choose jasmine over jest. Both are excellent libraries that have been around for a while and have an opinionated way of doing things that are quite similar. Jest is built on top of jasmine.One reason why you might choose jasmine over jest is that it is faster. (https://github.com/facebook/jest/issues/6694)

527 Views
SinonJS provides stand-alone test spies, stubs and mocks. It is a library that we can use to create object mocks for unit testing.Spies − Fake functions that we can use to track executions.Stubs −Functions replacements from which we can return whatever we want or have our functions work in a way that suites us to be able to test multiple scenarios.Mocks −Fake methodsAll these objects help in unit testing our code.

9K+ Views
JS has 2 notations for creating object properties, the dot notation and bracket notation.To create an object property from a variable, you need to use the bracket notation in the following way −Exampleconst obj = {a: 'foo'} const prop = 'bar' // Set the property bar using the variable name prop obj[prop] = 'baz' console.log(obj);OutputThis will give the output −{ a: 'foo', bar: 'baz' }ES6 introduces computed property names, which allow you to do −Exampleconst prop = 'bar' const obj = { // Use a as key a: 'foo', // Use the value of prop ... Read More

519 Views
You can't break from the forEach method and it doesn't provide to escape the loop (other than throwing an exception).You can use other functions like _.find from lodash instead −_.find − it breaks out of the loop when the element is found. For example,Example_.find([1, 2, 3, 4], (element) => { // Check your condition here if (element === 2) { return true; } // Do what you want with the elements here // ... });Throw an exception from forEach. For example,Exampletry { [1, 2, 3, 4].forEach((element) => { // Check your condition here if (element === 2) { throw new Error(); } // Do what you want with the elements here // ... }) } catch (e) { // Do nothing. }

2K+ Views
Window.location is the location property of a window and it is a reference to a Location object; it represents the current URL of the document being displayed in that window. Since window object is at the top of the scope chain, so properties of the window.location object can be accessed without window. prefix, for example window.location.href can be written as location.href. The following section will show you how to get the URL of page as well as hostname, protocol, etc. using the location object property of the window object. You can use the window.location.href property to get the entire URL ... Read More