Classes:
An object’s type is a class. The class tells you what properties and methods that type of object has. Here is how you would write a class in JavaScript:
var FidgetSpinner=function(color,shape) { this.color=color this.shape=shape } FidgetSpinner.prototype.spin=function() { //Do something here }
Objects:
Now that we learned about classes we can make an object
var spinner=new FidgetSpinner("color","shape")
let’s spin the spinner
spinner.spin()
1 thought on “Coding 1: Classes and Objects”
Comments are closed.