Where is the best place to place reader.close() in an async loop?
At the end of the completion callback.
What is the boilerplate code for inheritance in JavaScript?
Function.prototype.inherits = function (BaseClass) {
function Surrogate () {};
Surrogate.prototype = BaseClass.prototype;
this.prototype = new Surrogate();
};
function Dog (name) {
this.name = name;
}
Dog.prototype.bark = function () {
console.log(this.name + “ barks!”);
};
function Corgi (name) {
Dog.call(this, name);
}Corgi.inherits(Dog);
Corgi.prototype.waddle = function () {
console.log(this.name + “ waddles!”);
};
var blixa = new Corgi(“Blixa”);
blixa. bark();
blixa. waddle();
What does a Function object contain?
A string which contains the JS code of the function.
How do you find the distance in a 2D vector?
Dist([x_1, y_1], [x_2, y_2]) = sqrt((x_1 - x_2) ** 2 + (y_1 - y_2) ** 2)
What is the norm of a vector, and how do you find it?
The vector’s magnitude/length; the speed of a velocity vector.
Norm([x_1, y_1]) = Dist([0, 0], [x_1, y_1])
What is the difference between a position vector and a velocity vector?
A position vector has an x and y position, while a velocity vector has a speed in the x and the y directions.