JavaScript Why is Object.create() used in this case in prototypical inheritance? sap authorization object create user,create object based on user

Consider this code :-

function Rectangle(length, width) { 
    this.length = length;
    this.width = width;
}

Rectangle.prototype.getArea = function() {
    return this.length * this.width;
};

function Square(size) { 
    Rectangle.call(this, size, size);
}

Square.prototype = Object.create(Rectangle.prototype);

var rect = new Rectangle(5, 5);
var square = new Square(7);

console.log(rect.getArea());   // 25
console.log(square.getArea()); // 49

Why do we have to do the inheritance like this :-

Square.prototype = Object.create(Rectangle.prototype);

And not like this :-

Square.prototype = Rectangle.prototype;

They both seem to do the required task.

Answer:1

I am using https://github.com/fatlinesofcode/ngDraggable. <div ng-drag="true" ng-drop="true" ng-drag-start="example($data,$event)" > </div> The div is to be dropped right there where ...

I am using https://github.com/fatlinesofcode/ngDraggable. <div ng-drag="true" ng-drop="true" ng-drag-start="example($data,$event)" > </div> The div is to be dropped right there where ...

  1. allow drag div
  2. html5 allow drag element

I have an issue with the following code. I want to replace a string by another one, and generate an img code. However, I got an error message: str.replace is not a function. Any idea why? <...

I have an issue with the following code. I want to replace a string by another one, and generate an img code. However, I got an error message: str.replace is not a function. Any idea why? <...

  1. javascript replace function arguments
  2. javascript replace function not working
  3. javascript replace function string
  4. javascript replace function body
  5. javascript replace function with regex
  6. javascript replace function implementation
  7. javascript replace function with regular expression
  8. javascript replace function
  9. javascript replace function example
  10. javascript replace function parameter
  11. javascript replace function callback
  12. javascript replace function for special characters
  13. javascript replace function in object
  14. javascript replace function prototype
  15. javascript replace function not working in ie
  16. javascript replace function w3schools
  17. javascript replace function escape characters
  18. javascript replace function return value
  19. javascript replace function multiple
  20. javascript replace function browser compatibility

I have created a html dom structure like this. I have used the ng-click to toggle the visibility of the DOM structure. For example if I am clicking in menu1 and if it is not visible it will be make ...

I have created a html dom structure like this. I have used the ng-click to toggle the visibility of the DOM structure. For example if I am clicking in menu1 and if it is not visible it will be make ...

  1. toggle visibility html
  2. toggle visibility html element javascript
  3. toggle hide html
  4. toggle password visibility html
  5. toggle visibility javascript html
  6. toggle button visibility html
  7. toggle visibility of html element
  8. toggle visibility div html
  9. html toggle visibility without javascript
  10. html toggle visibility on click
  11. html toggle visibility jquery
  12. html toggle visibility checkbox

I am putting together an HTML5 form for music teachers so they can classify their music library a bit easier. One of the requested elements is a double handled range slider that would be able to ...

I am putting together an HTML5 form for music teachers so they can classify their music library a bit easier. One of the requested elements is a double handled range slider that would be able to ...