Chapter 16 - Javascript and PHP Validation and Error Handling Flashcards
Are JavaScript functions and variable names case-sensitive or case-insensitive?
JavaScript functions and variable names are case-sensitive. The variables Count, count, and COUNT are all different.
How can you write a function that accepts and processes an unlimited number of parameters?
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.
Name a way to return multiple values from a function.
One way to return multiple values from a function is to place them all inside an array and return the array.
When you’re defining a class, what keyword do you use to refer to the current object?
When defining a class, use the this keyword to refer to the current object.
Do all the methods of a class have to be defined within the class definition?
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.
What keyword is used to create an object?
New objects are created via the new keyword.
How can you make a property or method available to all objects in a class without replicating the property or methodwithin the object?
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 can you create a multidimensional array?
To create a multidimensional array, place subarrays inside the main array.
What syntax is used to create an associative array?
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”
//}
Write a statement to sort an array of numbers in descending numerical order.
A statement to sort an array of numbers into descending numerical order would look like this:
//numbers.sort(function(a, b){ return b - a })