The DOMRect() constructor in DOMRect API is used to create DOMRect object which represents a rectangle.
var myDOMRect = new DOMRect(x, y, width, height);
Parameters: This constructor contains four parameters as mentioned above and described below:
- x: It sets the x-coordinate of the rectangle.
- y: It sets the y-coordinate of the rectangle.
- width: It sets the width of the rectangle.
- height: It sets the height of the rectangle.
Example: This example creates a DOMRect object with given parameters.
- Before Click the button:
- After Click the Button console view:
Supported Browsers: The browsers supported by DOMRect() constructor are listed below:
- Google Chrome
- Safari 10.1
- Web API | DOMRect top property
- Web API | DOMRect right property
- Web API | DOMRect fromRect property
- Web API | DOMRect width property
- Web API | DOMRect height property
- Web API | DOMRect left property
- Web API | DOMRect bottom property
- HTML | DOM comment() constructor
- TypeScript | String Constructor Property
- How to detect if a function is called as constructor?
- Node.js | Constructor: new vm.Script() Method
- What is the Difference between Constructor and ngOnInit in AngularJS ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.