ES6 Flashcards
What is syntactic sugar?
syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express
syntactic sugar is syntax designed to make things easier to read / express
syntax to make things easier to read / express
what is the typeof an es6 class
what is the return of typeof an es6 class*
the typeof an es6 class = function
describe es6 class syntax
use the class keyword to create a class:
class ClassName { code block}
class name will be capitalized
always add a method named constructor()
class ClassName { constructor(value1, value2) }
the constructor() method is where you will create the object’s properties and use the arguments passed in as values for said property
constructor(value1,value2) {
this.property1 = value1;
this.propert2 = value2;
}
the constructor() method is automatically called if you create a new object
class ClassName { constructor() { ... } }
class Car { constructor(name, year) { this.name = name; this.year = year; } }
let car1 = new Car("Ford", 2014); let car2 = new Car("Mazda", 1994);
what is refactoring?
in computer programming, code refactoring is the process of restructuring existing computer code - changing the factoring - without changing its external behavior
code refactoring = restructuring existing code, changing the factoring without its external behavior
changing code while keeping the same function
ex: converting function to arrow function
What is a JavaScript class?
JavaScript class:
blueprint for creating objects
just special functions
templates for objects
it is NOT an object
it is a template for objects
used to create objects
what does an object constructor function do?
sometimes we need a template for creating many objects of the same “type”
to create an object type / template, we use an object constructor function
what is the constructor() method?
constructor() method:
special method of keyword class
automatically executed when a new object is created
creates and initializes an object instance of that class/type
used to initialize object properties PROPERTIES
it does not include the object’s methods
what does instantiated mean?
instantiation:
in programming, instantiation is the creation of a real instance or particular realization of an abstraction or template such as a class of objects
to create
in es6 context
const object = new ClassName(arg)
we just instantiated or created an object with whatever properties are within the constructor() method of the class ClassName
what does instantiated mean?
instantiation:
in programming, instantiation is the creation of a real instance or particular realization of an abstraction or template such as a class of objects
to create