In this example we put together a very small recipe for making circles programmatically as a way of illustrating the basics of creating a class (a recipe for making objects) in JavaScript.
Modify the code so that:
- …when the circles are places randomly, they are never placed such that the circle extends over the edge of the window
- …when you click on a circle, it migrates to a new location
- …instead of circles, n-pointed stars are rendered using multiple, rotated
div
s overlapping one another
- Eloquent JavaScript's chapter on object-oriented programming and "The Secret Life of Objects"
- MDN's "Working with Objects" and "Introduction to Object-Oriented JavaScript"
- This StackOverflow answer about the
new
keyword alongside MDN's own documentation of it.