Hi! This is a class
tutorial!
Here i will explain how to use classes
in your code.
What is a class?
A class
is a javascript feature, making modularity easy!
It works like a factory, making objects on demand!
Here’s a diagram:
Making a class on JavaScript
On Javascript, classes can be done with ease since ES6, with the class
keyword!
The following code will explain how to make a ES6 class:
class Car { // <- define a class like this
constructor(name, year) { // always put the constructor, it's essential for the class!
this.name = name; // while on the constructor, use this as the reference to your object
this.year = year;
this._kilometers = 0
}
drive(kilometers) { // <- this is a method, it is the way we add functions to our class
this._kilometers =+ kilometers
}
get kilometers() { // this is a getter, acts like a variable, but it's a function
return this._kilometers
}
}
Using classes with Clips on Wick Editor
Since i couldn’t come up with a simple class based idea for this, here’s some basic class code that makes a class with a clone of a clip attached:
class Clippo {
constructor(arg) {
this.arg = arg
this.clip = clip.clone()
}
}