Area: 20 Perimeter: 18
Here, the Rectangle() function serves as an outer scope that contains the variables required i.e. length, width, as well as the functions create(), getArea(), and getPerimeter(). All these together are the private details of this Rectangle module that cannot be accessed/modified from the outside. On the other hand, the public API as the name suggests is an object that consists of three functional members and is returned when the Rectangle function execution is complete. Using the API methods we can create and get the value of the area and perimeter of the rectangle.
Please Login to comment...