java functions can be
built-in or customized
java provides several built-in functions that have a rich collection of methods for performing
common math calculations, string manipulations, date manipulations, and array manipulations
customized function template
function name (input parameters, if any) {
//function code
}
three ways to return control to the point at which a function was invoked
t/f: a function can be considered as an object and referenced by a variable
true
function as object code
var obj = function(){
console.log(“Hello”);};
a function without a name is an
anonymous function
t/f: a function cannot be used as an argument to another function
false
function as arg for another function
window.setTimeOut(obj, 5000);
array
group of variables that have same name and are normally of same type
individual variable in array is called
element
refer to element in array by
giving array’s name followed by position number of element in square brackets
t/f: first element in array is zeroth element
true
5th element in array c is referred to as
c[4]
find length attribute of array
arrayname.length
java arrays are array _____
objects
what operator is used to create new array and to specify number of elements in an array
new operator
create new array ex
var n1 = [];
var n2 = new Array();
var n3 = [“Ford”, “Toyota”];
6 array methods
push()
adds new element to end of array
pop()
removes last element in array and returns the removed element
shift()
removes first element in array and returns it
concat()
concatenates two arrays into one
sort()
sorts an array