JavaScript Exam

2 hoursSections maybe lookinto 13.4 13.5

  • 15  Conventions, Data Types and Expressions
  • 4    Built-in Classes
  • 11  Arrays, Objects and Functions
  • 15  Classes
  • http://wiki.epic.com/main/Foundations/Training/WTC/Exams/JavaScript_Exam
  • http://wiki.epic.com/main/Foundations/Training/WTC/Reference/JavaScript/Basics

34 cards   |   Total Attempts: 188
  

Related Topics

Cards In This Set

Front Back
What are the built in Data Types? Which ones are primitive, and composite?
Primitive: Boolean, Number, String, Null, UndefinedComposite: Function, Object, Array (aside Array inherits from Object)
What are the specialized Data Types
Date
RegExp
Error
What is NaN
Its a value that stands for Not a Number.
How to convert variable x to Boolean?
Boolean(x) or !!x
What values are false when converted to boolean?
Undefined
null
empty string
0
NaN

What does "array[index]" do? What about "delete array[index]"?
Array[index] returns the value of the array stored at the index.delete array[index] the value at array[index] becomes undefined and the array.length remains the same.
What do the array methods pop, push, shift, and unshift do?
Pop() //removes and returns element from end of the arraypush(value)//pushes element onto end of array. Returns new lengthshift() //Removes and returns element from the front of the array and shifts all elements down.unshift(value)//Inserts value to front of array. Returns new length.
How does the array sort method work?
Array.sort() sorts array based on string order.array.sort(sortOrderFunction) sorts array based on sortOrderFunction.
What do the array functions concat, slice, and splice do?
Array0.concat(array1,...,arrayN) returns new array with values array0 - arrayN concatentated together. array0.slice(idx1) // returns new array w/ values staring from idx1array0.slice(idx1,idx2) // returns new array w/ values staring from idx1 to idx2-1.array0.splice(idx1, count) // deletes count elements from idx1 in array0array0.splice(idx1,count,val1,..,valN) // deletes count elements from idx1 and adds val1 - valN to array0
What is the format to set a functions as the value of a variable?
Var funVar = function Epic$Namespace$FunctionName(param1,...,paramN){ body;}
Why is it important to name functions?
It's important for debugging JavaScript errors, since the functionName will appear in the call stack.
Explain what the Arguments Object is and how it works?
It is defined within a function body. argument[n] // returns the nth argument passed in.argument.length // returns the number of arguments passed in.
What do the function properties length and prototype do?
FuncName.length // returns number of named parameters when funcName defined.funcName.prototype // Used when funcName is used as a constructor. Serves as template for an entire class.
What do the function methods apply, call and toString do?
Func1.apply(obj, argsArray); // invokes func1 as if it were a method inside obj. w/i func1 this refers to obj. func1.call(obj,arg1,...,argN); // same as apply but argsArray listed out.func1.toString(); // returns String representation of function. By default returns the code that is executed when func1 is invoked.
How do you define a class?
Create a function and attach a prototype to it. namespace.myClass = function namespace$myClass(param1){ this.__privateVal1 = param1; this.__privateVal2 = "abc"}namespace.myClass.prototype = { __privateVal1: 0, __privateVal2: "abc", classfunction1: function namespace$classfunction1() { //function body }}