- Constructor functions, by convention, start with an uppercase
- non-constructor (i.e. object literal) (it's actually called a
factory
):function createPokemon(name, type){ let object = { name: name, type: type, } return object }
- constructor function:
function Pokemon(name, type) {
this.name = name;
this.type = type;
}
- these look so similar to each other, so JS doesn't know that its a constructor function just by the function, it's how we CALL it that determines whether it's a constructor or not
- we make use of the
new
keyword, as follows:
let squirtle = new Pokemon('Squirty', 'water');
- example on inheritance (call and setPrototypeOf): Day08 demo
The DOM, objects and tables are all fundamental parts of what goes into building a dynamically generated website.
- Explain why we need domain modeling.
Domain modeling is the process of creating a conceptual model for a specific problem. The more efficiently we can solve the problem, the less resources ones application will run (e.g. an objects prototype when it runs more than once)
- Why should tables not be used for page layouts?
They are not responsive, and don't transfer well to different screen sizes
- List and describe 3 different semantic HTML elements used in an HTML .
<th>, <td>, <tr>
Table Header, Table Data, Table Row- What is a constructor and what are some advantages to using it?
constructor is a special method used to initialize and create objects of a class, they are more efficient.
- How does the term
this
differ when used in an object literal versus when used in a constructor?
- In an object literal, the term "this" refers to the object itself, representing the current instance of the object within the object's scope. It allows you to access and modify properties and methods of the object.
- In a constructor, the term "this" also refers to the object being created, but it represents the new instance being constructed, rather than an existing instance. It allows you to set and initialize properties and methods for the newly created object during the construction process.
Object Prototypes Using A Constructor
- Explain prototypes and inheritance via an analogy from your previous work experience. (NOTE: This is a very common front end developer interview question)
- Prototypes: protocols for assessing risk in customers based on the law
- Inheritence: business-specific (or even anecdotal) playbooks for different customers in different sectors
- Google Bard and ChatGPT