Reference Types Flashcards

0
Q

What are reference types?

A

Structures used to group data and functionality together

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

What is a reference value an instance of?

A

A specific reference type

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

Are there classes in JavaScript?

A

No. JacaScript does not support classss.

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

What is another name for reference types?

A

Object definitions

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

What is a constructor?

A

A simple function who’s purpose is to create an object.

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

What are objects an instance of?

A

A particular reference type.

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

What are two ways to create an instance of the Object type?

A
1. The new operator:
var person = new Object();
2. Object literal notation:
var person = {};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an expression context in ECMAScript?

A

A context in which a value (expression) is expected

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

How can you define an object so the Object constructor is never called?

A

An object defined via object literal notation never calls the Object constructor.

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

What type of data can an array hold?

A

Arrays can hold any type of data in each slot.

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

How are arrays sized?

A

Arrays are dynamically sized, automatically growing to accommodate any data that is added to them.

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

What two ways can arrays be created?

A
Using the array constructor:
var colors = new Array();
Using array literal notation:
var colors = [];
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you initialize an Array if you know the amount of items that will be in the array?

A

var colors = new Array(20);

This will create an array with an initial length of 20.

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

When an array is created using array literal notation is the Array constructor called?

A

No.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
What happens in this example:
var colors = ["red", "blue"];
colors[2] = "green";
A

The array length is automatically expanded to be that index plus 1

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

Where is the number of items of an array stored?

A

In the length property, which always returns 0 or more.

16
Q
What happens in the following example?
var colors = ["red", "blue", "green"];
colors.length = 1;
A

The last item is removed from the array. The length property is not read only.

17
Q

How can you add an element to the end of an array using the length property?

A

colors[colors.length] = “black”

18
Q

What is the maximum amount of items an array can contain?

A

4,294,967,295 items.

If you try to add more an exception occurs.

19
Q

What are two ways you can detect if a given object is an array?

A

The instanceof operator and the Array.isArray() method.

Use isArray if there are multiple global contexts

20
Q

When should you use Array.isArray();?

A

When detecting if an object is an array and dealing with multiple global scopes.

21
Q

How can you get a comma-separated string of all of the items within a given array?

A

colors. toString();

colors. valueOf();