I am posting here the Recent Elance And Odesk Javascript TestPapers.All are from odesk testpapers and I have given the answers too . If you have any other answer than the answer I have given please comment with the question number so that I can update if your answer will more appropriate than mine.I can say here that below quastions with answer is not only for odesk and elance javascript but it also for other examination of javascript papers. Also I can give you one tips here that before giving any exam or online exam please make sure you have read all the terms and policies with question pattern as well.So best of prepare well with below questions and answers then go for examination.

Recent Elance And Odesk Javascript TestPapers.
Recent Elance And Odesk Javascript TestPapers.

Q:1)which of the following will implement a singleton pattern in Javascript?

a)
    
b)
    
c)
    
d)
    

Q:2)which of the following determines whether cookies are enabled in a browser or not?

a)(navigator.cookie)? true : false
b)(application.cookieEnabled)? true : false
c)(navigator.cookieEnabled)? true : false
d)(applicatio.cookie)? true : false

Q:3)which of the following choices will change the source of the image to “image2.gif” when a user clicks on the image?

    a)img.id="imageID" src="image1.gif" width="50" height="60" onuousedown="changeimg(image1.gif)" onnouseup="changeimg(image2.gif)";
    b)img.id="imageID" src="image1.gif" width="50" height="60" onuousedown="changeimg(image2.gif)" onnouseup="changeimg(image1.gif)";
    c)img.id="imageID" src="image2.gif" width="50" height="60" onuousedown="changeimg(image1.gif)" onnouseup="changeimg(image2.gif)";
    d)img.id="imageID" src="image2.gif" width="50" height="60" onuousedown="changeimg(image2.gif)" onnouseup="changeimg(image1.gif)";


Q:4)In an HTML page, the form tag is defined as follows:

(form onSubmit=”return Validate()” action=”http://www.mysite.com/”>

The validate() function is intended to prevent the form from being submitted if the name field in the form is empty. what should the validate() function look like?

a)
    
b)
    
c)
    
d)
    


5)Consider the following code snippet:

    var myJSONObject = {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"};
    What is the best way to remove the property "regex", so the result would be this code snippet?
    myJSONObject == {"ircEvent": "PRIVMSG", "method": "newURI"};
    a)myJSONObject.regex.delete;
    b)myJSONObject.regex.remove;
    c)delete myJSONObject.regex;
    d)remove myJSONObject.regex;


6)which of the following Javascript Regular Expression modifiers finds one or more occurrences of a specific character in a string ?

    a) ?
    b) *
    c) +
    d) #


7)which of the following Array Ilethods in Javascript runs a function on every itell in the Array and collects the result from previous calls, but in reverse?

    a)reduce()
    b)reduceRight()
    c)reverse()
    d)pop()


8)what will be output of the following code?

function testGenerator() {
    yield "first";
    document.write('step1');
    yield "second";
    document.write('step2');
    yield "third";
    document.write('step3');
}

var g = testgenerator();
document.write(g.next());
document.write(g.next());
    a)firststep1second
    b)step1step2
    c)step1
    d)step1step2step3


9)which of the following code snippets changes an image on the page?

a)
    var img = document.getElementById("imageId");
    img.src = "newImage.gif";
b)
    var img = document.getElementById("imageId");
    img.style.src = "newImage.gif";
c)
    var img = document.getElementById("imageId");
    img.src.value = "newImage.gif";
d)
    var img = document.getElementById("imageId");
    img = "newImage.gif";


10)which of the following choices will remove a selection option from the code below?

    
    

a)
    
b)
    
c)
    
d)
    


11)which of the following code snippets shows an alert for an empty string?
var a = “”;

    a)If(a){ alert(‘This is empty string’);}
    b)If(a == NUL){ alert( ‘This is empty string’) ;}
    c)If ( !a){ alert( ‘This is empty string’) ; }
    d)If(a.empty){ a1ert(‘This is empty string’);}


12)How can created cookies be deleted using Javascript?

    a)They can't be deleted. They are valid until they expire.
    b)Overwrite with an expiry date in the past
    c)Use escape() on the value of the path attribute
    d)Use unescape() on the value of the path attribute
    e)The cookie file will have to be removed from the client machine.
    f)wait till the expiry date is reached


13)Consider the following image definition:


which of the following will change the image to companylogo2.gif when the page loads ?

    a)logo.source="companylogo2.gif"
    b)logo.source="companylogo1.gif"
    c)document.getElenentById('logo').src="companylogo1.gif"
    d)document.getElenentById('logo').src="companylogo2.gif"


14)Consider the following Javascript validation function:

    function ValidateField()
    {
        if(docunent.forms[0].txtId.value ==""){
            return false;
        }
        return true;
    }


which of the following options will call the function as soon as the user leaves the field?

    a)input nane=txtId type="text" onreset="return ValidateField()"
    b)input nane=txtId type="text" onfocus="return ValidateField()"
    c)input nane=txtId type="text" onsubmit="return ValidateField()"
    d)input nane=txtId type="text" onblur="return ValidateField()"


15)which of the following modifiers Ilust be set if the Javascript lastlndex object property was used during pattern matching?

    a) i
    b) m
    c) g
    d) s


16)Consider the three variables:

    someText = 'JavaScript1.2';
    pattern = /(\w+)(\d)\.(\d)/i;
    outcone = pattern.exec(someText);
    what does pattern.ignoreCase contain?
    a)true;
    b)false
    c)undefined
    d)null


17)which of the following is not a valid method in generator-iterator objects in Javascript ?

    a)send()
    b)throw()
    c)next()
    d)stop()


18)which of the following options can be used for adding direct support for XML to Javascript?

    a)E4X
    b)Regex
    c)Generators and Iterators
    d)let


19)which of the following code snippets will toggle a div element’s background color?

    
    
Change Background Color.

a)
     {
        terd.sty1e.backgroundColor = terd.style.backgroundColor == 'blue' ? 'red' : 'blue';
    };
    
b)
     {
        terd.sty1e.backgroundColor = terd.style.backgroundColor == 'blue' ? 'red' : 'blue';
    };
    
c)
     {
        terd.sty1e.backgroundColor = terd.style.backgroundColor == 'blue' ? 'red' : 'blue';
    };
    
d)
     {
        terd.sty1e.backgroundColor = terd.style.backgroundColor == 'blue' ? 'red' : 'blue';
    };
    


20)which of the following is not a valid method for looping an array?

a)
    var a= [1,2];
    for (var i = 0; i < a.length; i++) {
        a1ert(a[i]);
    }
b)
    var a= [1,2];
    a.forEach( function(item) {
        alert(item);
    })
c)
    var a= [1,2];
    a.nap( function(item) {
        a1ert(item);
    })
d)
    var a= [1,2];
    a.loop( function(item) {
        a1ert(item);
    })


21)which of the following choices shows the correct result for the code below?

    var arr = [];
    arr[0] = "Jani“;
    arr[1] = "Hege“;
    arr[2] = "Stale";
    arr[3] = "Kai Jim‘;
    arr[4] = "Barge";
    conso1e.log(arr.join());
    arr.sp1ice(2, 0, 'Lene");
    conso1e.log(arr.join());

a)
    Jani,Hege,Stale,Kai Jiu,Borge
    Lene,Jani,Hege,Sta1e,Kai Jiu,Borge
b)
    Jani,Hege,Stale,Kai Jiu,Borge
    Jani,Hege,Lene,Sta1e,Kai Jiu,Borge
c)
    Jani,Hege,Sta1e,Kai Jiu,Borge
    Jani,Hege,Sta1e,Kai Jin,Lene,Borge
d)
    Jani,Hege,Stale,Kai Jiu,Borge
    Jani,Hege,Sta1e,Kai Jin,Borge


22)A form contains two fields nailed idl and id2. How can you copy the value of the id2 field to idl?

    a)document.forms[0].idl.value=document.forms[0].id2.value
    b)document.forms[0].id2.value=document.forms[0].id1.value
    c)document.idl.value=document.id2.value
    d)document.id2.value=document.id1.value


23)which of the following will include a Javascript file in another Javascript file?
Note: There may be more than one right answer.

    a)Adding a script tag with the script URL in the HTML
    b)Loading it with an AJAX call then using eval
    c)Using 'import' operator
    d)Using ‘include’ operator


24)when setting cookies with Javascript, what will happen to the cookies.txt data if the file exceeds
the maximum size?

    a)The script automatically generates a run-tine error.
    b)The script automatically generates a load-tine error.
    c)All processes using document.cookie are ignored.
    d)The file is truncated to the uaxinuu length.


25)An image tag is defined as follows:


The purpose of the ImageChange() function is to change the image source to Image2.jpg. which of the
following should the ImageChange() function look like?

    a)document.getE1ementById('ERImage').src="Image1.jpg"
    b)document.getE1ementById('ERImage').src="Image2.jpg"
    c)document.getE1ementById('ERImage').style.src="Image1.jpg"
    d)document.getE1ementById('ERImage').style.src="Image2.jpg"


26)Consider the following Javascript function to change the color of the text box named txtName:

function color(col) {
    document.forms[0].txtName.style.background=col;
}


which of the following will change the color of the text box to green, as long as the user is
pressing a key?

    a)input type="text" onkeydown="color('white')" onkeyup="co1or('green')" name="txtName"
    b)input type="text" onkeydown="color('green')" onkeyup="co1or('white')" name="txtName"
    c)input type="text" onkeydown="color('white')" name="txtName"
    d)input type="text" onkeydown="color('green')" name="txtName"


27)which of the following functions determines whether the beginning of the paralll instance matches the
param2?

a)
    function (paraml, param2) {
        return param1.indexOf(param2) == 0;
    };
b)
    function (paraml, param2) {
        return param2.indexOf(param1) == 0;
    };
c)
    function (paraml, param2) {
        return param1.startsWith(param2) == 0;
    };
d)
    function (paraml, param2) {
        return param2.startsWith(param1) == 0;
    };


28)which of the following code snippets trims whitespace from the beginning and end of the given string
str?

    a)str. rep1ace(/^\s+|\s+$/g, '') ;
    b)str. rep1ace(/^\s+/g, '') ;
    c)str. rep1ace(/\s+$/g, '') ;
    d)str. rep1ace(/\s+/g, '') ;


29)In Javascript, the encodeURI() function is used to encode special characters. Which of the following
special characters is/are an exception to that rule?

A.£

B.€

C. Q

D. $

    a)A
    b)B
    c)C
    d)D
    e)A and B
    f)C and D


30)which of the following options is used to access the attributes in E4)(?

    a)@
    b)::
    c)#
    d)*


31)which of the following correctly sets a class for an element?

    a)document.getE1ementById(elementId).className = "Someclass";
    b)document.getE1ementById(elementId).class = "Someclass";
    c)document.getE1ementById(elementId).setAttribute("className","Someclass");
    d)document.getE1ementById(elementId).style = "Someclass";


32)which of the following statements regarding this String prototype is correct?

    String.prototype.doSomething = function(suffix) {
        return this.indexOf(suffix, this.1ength - suffix.1ength) !== -1;
    };
    a)This method deternines whether or not a string ends with another string.
    b)This method determines whether or not a string begins with another string.
    c)This method returns the position of the last occurrence of a specified value in a string.
    d)This method returns the position of the first occurrence of a specified value in a string.


33)what would be the default setting for the expires attribute of the document.cookie property?

    a)The duration of the browser session
    b)The duration the current document stays loaded
    c)Twenty-four hours from the tine the cookie is set
    d)There is no default setting
    e)The duration for which the machine is on

34)which of the following code snippets is more efficient, and why?



    a)Both are equally efficient.
    b)The first code is more efficient as it contains less code.
    c)The first code is more efficient as it employs object caching.
    d)The second code is more efficient as it employs object caching.


35)what value would Javascript assign to an uninitialized array element?

    a)NAN
    b)NULL
    c)undefined
    d)false
    e)0


36)what value would Javascript assign to an uninitialized variable?

    a)NaN
    b)undefined
    c)NULL
    d)false


37)How can a Javascript object be printed?

    a)console.1og(0bj)
    a)console.print(0bj)
    a)console.echo(0bj)
    a)none of these


38)which of the following will change the color of a paragraph's text to blue when a user hovers over
it, and reset it back to black when the user hovers out?

    a)

The text of theparagraph..

b)

The text of theparagraph..

c)

The text of theparagraph..

d)

The text of theparagraph..

e)

The text of theparagraph..

Recent Elance And Odesk Javascript TestPapers
Tagged on:             

One thought on “Recent Elance And Odesk Javascript TestPapers

  • October 13, 2015 at 1:24 pm
    Permalink

    where are the solutions?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *