Chapter 16 - Javascript and PHP Validation and Error Handling Flashcards

1
Q

Are JavaScript functions and variable names case-sensitive or case-insensitive?

A

JavaScript functions and variable names are case-sensitive. The variables Count, count, and COUNT are all different.

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

How can you write a function that accepts and processes an unlimited number of parameters?

A

To write a function that accepts and processes an unlimited number of parameters, access parameters through the arguments array, which is a member of all functions.

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

Name a way to return multiple values from a function.

A

One way to return multiple values from a function is to place them all inside an array and return the array.

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

When you’re defining a class, what keyword do you use to refer to the current object?

A

When defining a class, use the this keyword to refer to the current object.

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

Do all the methods of a class have to be defined within the class definition?

A

The methods of a class do not have to be defined within a class definition. If a method is defined outside the constructor, the method name must be assigned to the this object within the class definition.

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

What keyword is used to create an object?

A

New objects are created via the new keyword.

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

How can you make a property or method available to all objects in a class without replicating the property or methodwithin the object?

A

You can make a property or method available to all objects in a class without replicating the property or method withi the object by using the prototype keyword to create a single instance, which is then passed by reference to all the objects in a class.

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

How can you create a multidimensional array?

A

To create a multidimensional array, place subarrays inside the main array.

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

What syntax is used to create an associative array?

A

The suntax you would use to create an associative array is key : value, within curly braces, as in the following:

//assocaray = 
//{
//"forename" : //"Paul", 

//”surname” : //”McCartney”

//}

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

Write a statement to sort an array of numbers in descending numerical order.

A

A statement to sort an array of numbers into descending numerical order would look like this:

//numbers.sort(function(a, b){ return b - a })

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