Object Oriented Programming Flashcards
What is a method?
a function attached to an object
What does a method do?
perform a set of instructions written in the code block
What is this?
keyword that references the object
What does bind do?
returns a perman
What is the difference between a function and an object literal?
functions are objects that can be called
functions have a property named call: on them
What is the Prototypal Chain?
if javascript cannot find a method/property being called, it will go down the chain (__proto__) looking for that reference
What does the new keyword do?
Creates a blank, plain JavaScript object;
Links (sets the constructor of) this object to another object;
Passes the newly created object from Step 1 as the this context;
Returns this if the function doesn’t return an object.
What is the first thing that happens in a class when it is instantiated with the new keyword?
creates an empty object, then
calls the constructor method
Since classes are technically functions as well. Can you name a difference between classes and functions?
..
What is a static method?
methods that are attached to the creator object, but not to instantiated objects
What is the benefit of instantiating Classes within other classes?
so those classes inherit the properties of parents?
establishes a relationship/link between the two classes
(parent-child) relationship
Why are parent - child relationships important in OOP?
inheritance, reducing a lot of code
What is the basic idea of OOP?
replicate real life objects with code
What decides the order in which JS files must be loaded?
the order in which objects require data from other files
What is JSON?
JSON is a text-based data format following JavaScript object syntax
How to you serialize data into a JSON string using JavaScript?
JSON.stringify()
How do you deserialize a JSON string using JavaScript?
JSON.parse
What is a client?
The client asks for data
What is a server?
server sends data to client
Which HTTP method does a browser issue to a web server when you visit a URL?
Get requests
What are the formats of HTTP Requests and Responses?
.
How does ajax work?
.
How do you specify the request method (GET, POST, etc.) when calling ajax?
use the method property with value you want (ie “GET”)
Why might you need to build elements dynamically with data from an AJAX request?
a database of information can change and you have more flexibility with dynamic elements
Should you use named functions or anonymous functions for success and error handlers?
generally should use named functions