Classes Flashcards
What are classes in relation to JavaScript and Object Oriented Programing (OOP)?
Classes are a method for a developer to create similar objects quickly.
How are classes useful in object creation?
They allow us to reduce duplicate code and the time taken to debug a program.
What is one key difference in the syntax between objects and classes in JavaScript.
Classes contain a constructor method that allows the building of the initial key:value of the new object created by the Class.
By convention, how should we name our Classes in JavaScript?
They should be named in CamelCase but with a starting Capital letter.
What is a class instance in JavaScript?
An instance is an object, created using the Class, but with key:value pairs specific to that object
How do we create an instance of a class in JavaScript?
We use the ‘new’ keyword:
const objectName = new ClassName(‘parameter’)
Syntactically, what is different between methods in Objects and Classes?
You cannot use commas to separate methods in Classes