Objects Flashcards

(14 cards)

1
Q

What is a method in javascript

A

Methods are properties that contain a Function() object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give a constructor example

A
var Person = function(living,age,gender){
this.living = living;
...
}
var Cody = new Person(true,33,male);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the Object() object

A

An empty generic object container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the two methods of object creation

A
1) via a custom constructor
var Car = function Car(color);
var redCar = new Car('red');
2) Via the Object() constructor:
var redCar = new Object();
redCar.colorc = 'red';
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Explain the ‘new’ keyword

A

When using new, javascript sets the value of ‘this’ to the newly constructed object. And the new object will be returned by default instead of ‘false’.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the nine native (global) object constructors

A

Number(), String(), Boolean(), Object(), Array(),Function(), Date(), RegExp(), Error()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are literals

A
Shortcuts for manufacturing most of the native object values without having to use new Foo() or new Bar().
E.g. var myNumber = new Number(23);
var myNumberLiteral = 23;
var myObject = new Object();
var myObjectLiteral = {};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Give an example of a function literal

A
var myFunction = new Function("x","y","return x*y");
var myFunctionLiteral = function(x,y) {return x*y}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Give an example of an array literal

A
var myArray = new Array('foo','bar');
var myArrayLiteral = ['foo','bar'];
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are primitive values?

A

Values that are simple, irreducible, not made up of other values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How are primitive values stored/copied?

A

the value is literally copied/stored.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How are complex values stored/copied?

A

by reference.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you refer to the constructor of an object?

A

All objects have a constructor property

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you know if an object is an instance of a constructor function?

A

by using the instanceof keyword

How well did you know this?
1
Not at all
2
3
4
5
Perfectly