JavaScript 1.8 Fiverr Test

What will be printed on the standard output console on the execution of the following JavaScript code?
var var1 = 10;
document.write("First Value: " + var1 + " and Second Value: " + var2);
var var2 = 20;

First Value: 10 and Second Value: undefined
First Value: 10 and Second Value: 20
First Value: undefined and Second Value: undefined
The code will generate an error.

While working with JavaScript Page Redirection, which of the following options is an invalid method of the window.location object?

location.reload()
location.replace()
location.reassign()
window.navigate()

Consider the following snippet code:
console.log(null == undefind);
The result would be.

true
false
error on code
No ountput

Which of the following JavaScript methods is used to return the primitive value of a Boolean object?

toSource()
toFixed()
ValueOf()
map()

In relation to object oriented JavaScript, which of the following options are the correct attributes of the object properties?

readable
writable
enumerable
configurable

What will be the correct output of the following JavaScript code?
<html>
   <head>
   <title>objects</title>
      <script type="text/javascript">
         function bk(tt, th){
            this.tt = tt;
            this.th  = th;
         }
      </script>
   </head>
   <body>
      <script type="text/javascript">
        var myBk = new bk(39, 41);
        document.write(myBk.th + "<br>");
        document.write(myBk.tt + "<br>");
        var i = 1, m,j = 1 ;
        for ( m=1;m<=5 ;m++ )
        {
            if ( i > 5 )
                break;
            else
                j += i-- ;
            document.write(j+myBk.tt+myBk.th);
            i += j;
            j=j+7;
        }
      </script>
   </body>
</html>

39
41
8129

41
39
8231

39
41
8271

41
39
8291

Consider the following snippet code:
function test(){
return
{
test:1
};
}
alert(typeof test());
What will be the above alert ?

number
function
undefind
nul

What will be the output of the following JavaScript code?
var n=1;
var a=33;
var b;
b = a<<4;
b = a>>3;
b = b + 2;
while(b>=1){
   n = n + b;
   b = b - 1;
}
function ab(n) {
   if (n < 2) {
      return n;
   } else {
      return ab(n - 1) + ab(n - 2);
   }
}
console.log(n + ab(9));

52
53
54
56

Which of the following JavaScript objects is used to store unique values of any type?

Object
Set
String
Map

What is the purpose of the assign() method?

Only loading
Unloading of window
Displays already present window
Loading of window and display

Which of the following options is the correct syntax of the Object.getOwnPropertyDescriptor method that is used for querying the full information about a property?

let d = Object.getOwnPropertyDescriptor(propertyName, obj);
let d = Object.getOwnPropertyDescriptor(obj, propertyName, descriptor);
let d = Object.getOwnPropertyDescriptor(obj, propertyName);
let d = Object.getOwnPropertyDescriptor(obj, descriptor);

Consider the following code snippet.
var test = function test(){
console.log("2" - - "2");
};
test();
What does the above code do?

22
2
4
0

Find the correct output of the following JavaScript code.
<html>
   <head>
      <title>objects</title>
      <script type="text/javascript">
         var pk = new Object();
         pk.su = 32;
         pk.au  = 63;
      </script>
      </head>
      <body>
       <script type="text/javascript">
            var as=pk.su + pk.au;
            var num,i=1,j,k;
            num=as+266;
            while(i<=num)
            {
                k=0;
                if(num%i==0)
                {
                    j=1;
                    while(j<=i)
                    {
                        if(i%j==0)
                        k++;
                        j++;
                    }
                    if(k==2)
                        document.write(i);
                }
                i++;
            }
       </script>
  </body>
</html>

19
21
23
25

Consider the following snippet code:
let x = function()
{
  const c;
  c = 10;
  console.log( c);
}
x();
The result would be.

10
null
empty
undefined

While using JavaScript, which of the following options can be used to return a number between 0 and 50?

Math.floor(Math.random() & 50);
Math.floor(Math.random() * 51);
Math.floor(Math.random() * 51) + 1;
Math.floor(Math.random() @ 50)

setTimeout() present in which object in java script?

location
element
window
None of the mentioned

Which of the following method of Int8Array object is used for testing if all array elements pass the test given by a function or not?

Int8Array.prototype.entries()
Int8Array.prototype.every()
Int8Array.prototype.find()
Int8Array.prototype.map()

Consider the following code snippet :
var test = function test(){
console.log(window.location === document.location);
};
test();
The output would be :

False
True
0
1

What we can use to restart the inner most loop in java script.

Using about.
Using brackloop
Using stop
Using continue lable

Using DATE object which of the following you to call a function based on elapsed time?

setElapsedTime()
timeout()
setTimeout()
setTime()

What will be the correct output of the following JavaScript code?
<html>
   <head>
   <title>objects</title>
      <script type="text/javascript">
        function primes(nt){
            with(this){
               pr = nt;
            }
         }
         function bk(tt, au){
            this.tt = tt;
            this.au  = au;
            this.pr = 1;
            this.primes = primes;
         }
      </script>
   </head>
   <body>
      <script type="text/javascript">
        var myB = new bk(2,11);
        myB.primes(9);
        var x=myB.tt + myB.au + myB.pr-19,p=1,i;
        var i=1,j=0,k=0,m=1.5,s=0;
        while(i<=x)
        {
            j=1;
            while(j<=4)
            {
                k=1;
                while(k<=4)
                {
                    if(k%2!=0)
                    {
                        s=s+i+j+m;k++;
                    }
                    else
                    {
                        k++;m++;
                    }
                }
                j=j+2;m++;
            }
            i++;m++;
        }
        document.write(s);
      </script>
   </body>
</html>

164
171
174
178

What will be the output of the following JavaScript code?
'use strict'
class Abc{
   constructor(t, p) {
      this.t = t;
      this.p = p;
   }
   test() {
      var x;
      var c = 0;
      for(x=7; x!==0; x&=(x-1))
      c++;
      console.log(c++ + this.t + this. p);
   }
}
var Obj1 = new Abc(10.5,20.5);
Obj1.test();

33
34
35
36
The code will generate an error.

In relation to Accessor descriptors, which of the following properties are not available?

get function
set function
value
writable

Consider the following code snippet
var x = 3;
var foo = {
x:2,
baz:{
x:1,
bar:function(){
return this.x;
}
}
}
var go = foo.baz.bar;
alert(go());
alert(foo.baz.bar());
What does the above code do?

1,2
1,3
2,1
3,1

Which of the following is the correct syntax of DataView view of JavaScript?

new DataView( byteOffset, [byteLength])
new DataView(buffer, length [, byteOffset [, byteLength]])
new DataView(buffer [, byteOffset [, byteLength]])
new DataView(object, buffer [, byteOffset ])

Carefully analyze the following code and answer the given question.
var main = function() {
   var x=15
   var p=1
   for(var i=2;i<=x/2;i++) {
      if(x%i==0)
      p=0;
   }
   if(p!=1)
   console.log("failure") ;
   else
   console.log("success");
}
main();
If the value of variable "x" is 15, then the output of the above program is "failure". What will be the outputs of the above code in two different executions, if we input the values of variable "x" as 23 and 63?

success, success
success, failure
failure, success
failure, failure

Consider the following code
var str = "I have an account on facebook";
var s = str.search(/ACEBOOK/i);
console.log(s);
The output would be :

-1
1
21
22

In relation to object oriented JavaScript, which of the following options can be used as the value of F.prototype?

An object.
Null
0
1

Which is the event that fire when the form element button textarea loses the focus?

onclick
onblur
ondbclick
onfocus

What will be the correct output of the following JavaScript code?
'use strict'
class Xw{
  constructor(t, p) {
     this.t = t;
     this.p = p;
  }
  pp() {
     var x=49;
     var c = 21;
            if(x=7)
                c++;
            else if(x>6)
                c=c+8;
            else
                c=c*4;
           document.write(c++ + this.t + this. p*2);
  }
}
var Obj1 = new Xw(19,29);
Obj1.pp();

77
88
99
111

Consider the following code snippet :
const x = 'constructor'
console.log(x[x](01))
The output would be :

undefind
1
1
0

Name the different primitive data types of JavaScript ?

Boolean.
Number.
String.
Null.
Undefined.
Symbol.

Boolean.
Number.
String.
Undefined.
Symbol.

String, Undefined, Number, Viod
Boolean,Function

String, Undefined, Integer, Viod
Boolean,Function

What will be the correct output of the following JavaScript code?
'use strict'
class Xw{
  constructor(a, b){
     this.a = a;
     this.b = b;
  }
  tt() {
     var x;
     var c = 3;
           for(x=37; x!==0; x&=(x-1))
                   c++;
           document.write(c++ + this.a + this. b + 2 *2);
  }
}
var Obj1 = new Xw(23.5,26.5);
Obj1.tt();

58
60
62
68

With regard to Math object in JavaScript 1.8, which of the following statements are true?

All properties of the Math object are non-static.
All methods of the Math object are static.
Math.trunc() method always returns integral part of the given number.
Math is a constructor object.

What will be the correct output of the given JavaScript code?
<html>
   <head>
   <title>User objects</title>
      <script type="text/javascript">
        function dd(nt){
            with(this){
               pr = nt;
            }
         }
         function bk(tt, au){
            this.tt = tt;
            this.au  = au;
            this.pr = 1;
            this.dd = dd;
         }
      </script>
   </head>
   <body>
      <script type="text/javascript">
        var myB = new bk(12,21);
        myB.dd(9);
        var x=myB.tt + myB.au + myB.pr-19,p=1,i;
        for(i=x;i<=x/2;i++)
        {
            if(x%i==0)
                p=0;
            else
                p=1;
        }
        if(p!=1)
            document.write(x+"failure");
        else
            document.write(x+"success");
      </script>
   </body>
</html>

29success
32failure
23success
28failure

What will be the correct output of the following JavaScript code?
<html>
   <head>
   <title>User-defined objects</title>
      <script type="text/javascript">
         function sad(am){
            this.pr = am;
         }
         function sbk(tt, th){
            this.tt = tt;
            this.th  = th;
            this.sad = sad;
         }
      </script>
   </head>
   <body>
      <script type="text/javascript">
        var myBk = new sbk(4,7);
        myBk.sad(8);
        document.write(myBk.tt + myBk.th + myBk.pr);
        var i,j,k,m,n;
        i=9;j=56;k=4;m=78;n=22;
        while(i<=14)
        {
            do
            {
                m=i<j;
                n=m>i;
                k=n*5+m-4;
                j++;
            }while(j<=60);
            i++;
        }
        document.write(i+j+k+m+n+myBk.tt + myBk.th + myBk.pr);
      </script>
   </body>
</html>

1996
1997
1998
1999

which is not a JS window method.

modify()
resizeTo()
moveTo()
open()

Which javascript method can be used to create or modify the attribute properties

defineProperty()
defineProperties()
Both defineProperty() and defineProperties()
None of the mentione

What will be the output of the following JavaScript code?
var a = 5;
var b = 2;
var c = a / b;
var c = a * b
var c = a % b
var c = a + b * a;
document.write(c);

2.5

15

35

2.5
10
1
15

Timer value can be cleared using which function in java script?

clearTimervalue()
clearTimeout()
clear()
flush(timer)

What will be the correct output of the following JavaScript code?
<html>
<head>
    <title>Objects!!!</title>
    <script type="text/javascript">
      var s = new Object();
      s.Name = "Mary";
      s.Surname = "Jane";
      s.id = 10;
      s.Eng_mark = 80;
      s.Math_mark = 86;
      s.Science_mark = 92;
      s.findAverage = function()
      {
          return (s.Eng_mark + s.Math_mark + s.Science_mark)/3;
      };
      s.result = function()
      {
        document.write("Student Id: " + s.id + "<br />");
        document.write("Student Name: " + s.Name + " " + s.Surname + "<br />");
        var a = s.findAverage();
        document.write("Average Marks: " + a);
      };
        s.result();
    </script>
</head>
<body>
</body>
</html>

Student Id: 10
Student Name: Mary
Average Marks: 86

Student Id: 10
Student Name: Mary Jane

Student Id: 10
Student Name: Mary Jane
Average Marks: 86

Code will throw an error.

What will be the correct output of the following JavaScript code?
<html>
   <head>
      <title>Object oriented Javascript()</title>
   </head>
   <body>
      <script type="text/javascript">
      'use strict'
class Art{
    succ() {
    var i=3,j,k=0;
    for(j=i;j<=7;j++)
    {
        k=j+i;
        if(k>=7)
        {
            k=k+3;
        }
        else
        {
            k=k-2;
        }
    }
    document.write(k-2 +"<br>");
}
}
var waj = new Art();
waj.succ();
      </script>
   </body>
</html>

8
9
10
11

In relation to object oriented JavaScript [[Prototype]] property, which of the following statements is/are correct?

The prototype is only used for reading properties.
The write/delete operations cannot work directly with the object for data properties.
Both statements a and b are correct.
Neither statement a nor b is correct.

Find the output of the following JavaScript code.
var str = "Example, JavaScript, Test";
var res = str.substring(6,15);
document.write(res);

le, JavaSc
l, c
e, JavaSc
No output will be displayed.
The code will give an error.

What will be the output of the following code?
function* as( limit = Infinity )
{
   let a = 0, b = 1;
   while( a < limit )
   {
      yield a;
      [a, b] = [b, a + b];
   }
}
var pp=3
let iterator = as( 10 );
for(var prop of iterator){
   pp=pp+23
}
var f = (x)=>10+x
console.log(f(10) + pp)

170
178
184
190

How do you prompt user with message and at the same time request user input?.

alert()
prompt()
display()
confirm()

In relation to JavaScript prototype, which of the following methods is used for returning an array of all own property names?

Object.getPrototypeOf(obj)
Object.getOwnPropertyNames(obj)
Object.keys(obj)
Reflect.ownKeys(obj)

What will be the correct output of the following JavaScript code?
'use strict'
class Sf{
    success_failure() {
    var a = 28, s=0, i ;
    for(i=1;i<=a;i++)
    {
        if(a%i==0)
          s=s+i;
    }
    if(s!=a*2)
      document.write("failure") ;
    else
      document.write("success");
  }
}
var pj = new Sf();
pj.success_failure();

success
failure
Code will execute but will not give any output.
Code will give a compilation error.

Which of the given options is the correct output of the following JavaScript code?
var a = 20 + "Example" + 10 + "Test";
var b = 20 + 10 + "Test" + "Example" ;
document.write(a, "<br>");
document.write(b);

30ExampleTest
30TestExample

20Example10Test
2010TestExample

20Example10Test
30TestExample

No output will be displayed.

In relation to object oriented JavaScript, for which of the following options no wrapper objects are provided?

Nul
Undefined
Both options a and b.

Find the output of the following JavaScript code and choose the correct answer from the given options.
<html>
   <head>
      <title>objects</title>
      <script type="text/javascript">
         var pk = new Object();
         pk.su = 34;
         pk.au  = 67;
      </script>
      </head>
      <body>
       <script type="text/javascript">
            var i,j,k;
            var as=pk.su + pk.au;
            for(i=5;i<=9;i++)
            {
                for(j=-6;j<=-2;j++)
                {
                    for(k=1;k<=i;k++)
                    {
                        k++;
                    }
                }
                j--;
            }
            j=j+3
            document.write(as+j-23);
       </script>
  </body>
</html>

90
81
79
98

Which of the following statements about JavaScript REFLECT object is NOT correct?

The Reflect.preventExtensions() method returns a string.
Reflect.get() method is used for returning the value of properties.
The Reflect object cannot be used with a new operator.
The Reflect.isExtensible() method provides the same functionality as that of Object.isExtensible() method.

Consider the following code
var str = /u/.exec("I am the best friend!");
console.log(str);
The output would be :

true
false
undefind
null

What will be the output of the following JavaScript code?
var str1 = "Hi world";
var str = "Apples are round, and apples are juicy";
var sliced = str.slice(5, -2);
var text ='Apple \nJuice'
var raw_text = String.raw'Apple \nJuice'
console.log(str1.valueOf());
console.log(raw_text)
console.log(sliced);
console.log(text)

Hi world
Apple
Juice
s are round, and apples are jui
Apple
Juice

Hi world
Apple \nJuice
s are round, and apples are jui
Apple
Juice

Hi world
Apple \nJuice
les
Apple
Juice

8
Apple \nJuice
les
Apple
Juice

In relation to sealing an object globally, which of the following methods returns true if adding, removing, and changing properties is forbidden and all the current properties are configurable: false, writable: false

Object.freeze(obj)
Object.isFrozen(obj)
Object.isSealed(obj)
Object.preventExtensions(obj

Which of the following methods can accept negative indexes?

substring()
slice()
Both options a and b.
Neither option a nor b.

Which function of the Object constructor with regard to JavaScript 1.8 returns the array of names of only enumerable properties of the given object?

Object.keys()
Object.getOwnPropertyNames()
Object.getOwnPropertyDescriptor()
Object.getPrototypeOf()

Which of the following properties of a JavaScript Array object is only present in the arrays that are created by regular expression matches?

length
prototype
index
input

JavaScript 1.8 Fiverr Test 2020