Posts

Showing posts from December, 2014

Elance Ajax Test Answers

Which protocol is used to transfer data in an AJAX request? Hypertext Transfer Protocol, HTTP Which property of the popstate event contains a copy of the history entry’s state object? state What's wrong with the following code? function check_for_request_done() { if (xhr.readyState == 4) { clearInterval(timer); do_something_with_result(xhr); } } var xhr = new XMLHttpRequest(); xhr.open("GET", "/resource", true); xhr.send(); var timer = setInterval(check_for_request_done, 100); This code is polling a timer rather using the onreadystatechange event to check the state of the async request. In non-IE browsers, what attribute should you check your XMLHttpRequest object for in order to see if it supports CORS? withCredentials What is the value of the response property of XMLHttpRequest object if readyState property equal to 3? null What arguments MUST be supplied to an XMLHttpRequest object’s .op

JavaScript Test Answers

JavaScript is … object based How can you get the square root of 2 in JavaScript? Math.SQRT2 What is the result? “” ? “a” : “b” “b” Consider: var x = [‘a’, ‘b’, ‘c’]; Which line of code will remove the first element of the array, resulting in x being equal to [‘b’, ‘c’]? x.splice(0, 1); var foo = ‘Global'; function fun() { log( foo ); var foo = ‘Local'; log( foo ); } fun(); What the output of the above to log()? undefined Local var y = 3, x = y++; What is the value of x? 3 You use the  Math.tan ( ) method to: Return the tangent of an angle (in radians) What is the value of x after the following statement? var x = 1 == ‘1’; true Which fact is true about the keyword “default”? It catches any case clauses not caught by case statements within a switch statement What is the end value of myAddedVar with the following code: var myVar = ‘5’; var myAddedVar = myVar + 10; ‘510’ What is the value of `x` after the following? var x = “hello”; (function() { x