What is JSONP used for?
- Tracking and analyzing JSON requests
- Validating JSON requests
- Cross-domain requests
- Standardizing JSON requests
Answer: Cross-domain requests
When is a variable that a closure used generally released?
- When the variable's owning scope is released
- Never
- When it goes out of scope
- When the function closure goes out of scope
Answer: When the function closure goes out of scope
Which of the following invokes a user-defined object constructor function?
- myConstructor x = create myConstructor();
- var x = new myConstructor();
- myConstructor x = new myConstructor();
- var x = create myConstructor();
Answer: var x = new myConstructor();
Which character ends a JavaScript statement?
- An exclamation mark "!"
- A semicolon ";"
- A period "."
- A colon ":"
Answer: A semicolon ";"
Can you embed comments inside of statements? For instance: if (true /* this is a comment */) { }
- Yes
- No
Answer: Yes
Given the following, what is the value of x? var x = typeof null;
- null
- "null"
- "object"
- undefined
Answer: "object"
Which of the following array object functions modifies the array when called?
- slice()
- concat()
- pop()
- splice()
Answer: splice()
Which of the following variable types does not exist in JavaScript?
- double
- boolean
- number
- string
Answer: double
Which is not a way to construct an array in JavaScript?
- var x = new Array(1,2,3);
- var x = array();
- var x = [];
- var x = [1,2,3];
Answer: var x = array();
Which of these is NOT a logical operator?
- &&
- &
- !
- ||
Answer: &
What is the value of thisVar in the following example? var thisVar;
- undefined
- null
- nothing
- 0
Answer: undefined
Which of the following is a correct method for creating an empty array?
var myArray = ();var myArray = new Array[];var myArray = [];var myArray = array();
Answer:
var myArray = [];
What is the value of the following expression? 8 % 3
- 2
- Other/Error
- 24
- 5
Answer: 2
Based on the following, what is the value of
x? var a = "A"; var x = a.concat("B");
- "B"
- ["A", " B"];
- "AB"
- "A"
Answer: "AB"
What does Math.pow(2, 3); return?
- 2 raised to the power of 3
- A random value between 2 and 3
- Variable values 2 and 3
- 6
Answer: 2 raised to the power of 3
What does the try statement do?
- It allows you test a block of code for errors.
- It asynchronously attempt to call a function.
- It attempts an HTTP request to the given URL.
- It attempts to call a function.
Answer: It allows you test a block of code for errors.
Which operator is used for string concatenation?
- &
- .
- +
- -
Answer: +
Which of the following is an Error object constructor?
- SyntaxError
- GrammarError
- EmergencyError
- StopError
Answer: SyntaxError
Which of these is a declaration in JavaScript?
- var x = 0;
- if (true) {}
- function foo() {}
Answer: var x = 0;
How do you round the number 7.25 to the nearest whole number?
- round(7.25)
- rnd(7.25)
- Math.round(7.25)
- Math.rnd(7.25)
Answer: Math.round(7.25)
Is JavaScript limited to a single file of code?
- No
- Yes
- Depends on the platform
Answer: No
Which of the following primitive values exist in JavaScript?
- linked list
- time
- tree
- boolean
Answer: boolean
Which character combination is used to create a single line comment?
- !!
- $$
- //
- --
Answer: //
Split() is a method of which constructor's prototype?
- RegExp.prototype
- String.prototype
- Array.prototype
- Number.prototype
Answer: String.prototype
How do you remove a property from an object?
- remove myObj.myProp
- delete myObj.myProp
- myObj.myProp.delete()
- myObj.properties.remove("myProp")
Answer: delete myObj.myProp
What is the difference between the following two class implementations?
First: function Animal() { this.feed = function () { } }
Second: function Animal () { } Animal.prototype.feed = function () { };
- The second class creates a copy of the feed function for every instance; the first shares a single implementation
- They are the same
- The first class creates a copy of the feed function for every instance; the second shares a single implementation
Answer: The first class creates a copy of the feed function for every instance; the second shares a single implementation
Which character combination is used to alter the order of operations by grouping expressions?
- [ ]
- { }
- < >
- ( )
Answer: ( )
Which of the following is the syntax for an object literal (with no properties)?
- {};
- [];
- nil;
- ();
Answer: {};
JavaScript is an implementation of which language standard?
- ActionScript
- ECMAScript
- VBScript
- HTML
Answer: ECMAScript
How is an object property referenced?
- myObj<foo>
- myObj.foo
- myObj:foo
- myObj(foo)
Answer: myObj.foo
When handling an exception, which statement lets you handle the error?
- try
- catch
- finally
- throw
Answer: catch
What is the logical not operator in JavaScript?
- ~
- !
- --
- |
Answer: !
How do you find the number with the highest value of x and y?
- Math.max(x, y)
- Math.floor(x, y)
- Math.top(x, y)
- Math.ceil(x, y)
Answer: Math.max(x, y)
Which statement loops through an array?
- for (i < myArray.length; i++)
- for (i = 0; i; i <= myArray.length;)
- for (var i=0; i < myArray.length; i++)
- for (i=myArray.length; i>=0; i--)
Answer: for (var i=0; i < myArray.length; i++)
Which character ends a JavaScript statement?
- A period "."
- An exclamation mark "!"
- A colon ":"
- A semicolon ";"
Answer: A semicolon ";"
What is the following construct generally used for in JavaScript? (function () { // ... })();
- This has no effect
- To create a scope to protect code from the global scope
- To enforce strict compilation of JavaScript
- To force code to parse in a particular order
Answer: To create a scope to protect code from the global scope
How do you create an empty array using literal notation?
- var x = [Array()];
- var x = [];
- var x = [1, 2, 3];
- var x = Array();
Answer: var x = [];
Does the order of arithmetic operators matter?
- Yes
- No
Answer: Yes
What will the data look like after execution of the following code?
var data = [1, 2, 3, 4, 5, 6]; data.shift();
- [undefined, 1, 2, 3, 4, 5]
- [1, 2, 3, 4, 5]
- [6, 1, 2, 3, 4, 5]
- [2, 3, 4, 5, 6]
Answer:[2, 3, 4, 5, 6]
How do you add a new object into an array?
- myArray.add(newMember);
- myArray.push(newMember);
- myArray.pop(newMember);
- myArray.insert(newMember);
Answer: myArray.push(newMember);
Which of the following variable types does not exist in JavaScript?
- string
- double
- boolean
- number
Answer: double
What happens when the following code is executed?
function foo() { this.me = "hello"; } var x = foo(); console.log(x.me);
- "hello" is written to the console
- Runtime exception: property 'me' not found on undefined.
- Syntax error
Answer: Runtime exception: property 'me' not found on undefined.
Which of the following array object functions modifies the array when called?
- concat()
- pop()
- splice()
- slice()
Answer: splice()
Do you need to use the class pattern to be object-oriented using JavaScript?
- No
- Yes
Answer: No
No comments:
Post a Comment