JavaScript Тест Upwork

Select the statement that will return false. First line in file is: var a = true; b = false;

    This code will throw an error
    delete a === b
    delete a
    delete b
    delete c

Which of the following  is true for Creational design patterns?

    Creational design patterns minimal impact on overall object relationships and more controlled     mechanisms of object creation
    Creational design patterns are all about the composition of objects and relationships among them
    Creational design patterns deal with various mechanisms of object creation
    Creational design patterns focus on the interdependency and communication between objects

Select all statements that will return true. Object is defined: let a = {a:1};
Note: There may be more than one right answer.

    delete a.a;
    delete a.b;
    1 != Boolean('-1')
    Boolean(1) == Boolean('-1')
    Boolean(null) != Boolean('0')
    All of them will return true

How can you create a function with the JavaScript Function constructor ?

    var func = Function("x","y","return x+y");
    var func = new Function("x", "y", "return x + y")
    var func = Function(x,y){ return x+y;}
    None of the above

Which example is correct of Local Scope Variable?

    var b = 3;
function myFunc() {
  return b * b;
}

    function myFunc() {
 var b = 3;
 return b * b;
}

    var a = 2;

function myFunc(){
   console.log(a);
}

    All of the above

Which is the correct way to create an Object?

    var fooObj = new Object()
    var fooObj = {}
    Both of the above
    None of these

What will be logged to the console?
console.log([0, 0, 0].fill(1, 1));

    RangeError
    SyntaxError
    EvalError
    [0, 1, 1]
    [1, 1, 1]
    [1, 0, 0]
    [0, 1, 0]

How can you set DOM element style assuming there is an element with id="id"?
Note: There may be more than one right answer.

    document.getElementById('id').setAttribute("style", "color: red; font-size: 10px");
    document.getElementById('id').style.cssText = 'color: red; font-size: 10px;';
    document.getElementById('id').style.color = 'red';
    document.getElementById('id').style.text.color = 'red';

Which of the following represents when a  String object splits a String object into an array of strings by separating the string into substrings?

    slice()
    split()
    replace()
    search()

What will be printed on the browser console by following code:-
console.log(parseFloat("9. Hello World "));

    9. Hello World
    9.9 Hello World
    Number
    9

Which of the following code samples prints false?

    var n = 3.2;
alert(n===+n && n!==(n|0));

    var n = 3;
alert(n===+n && n===(n|0));

    var boolValue = new Boolean(«false»);
alert(boolValue);

    var n=3.2;
alert(n % 1 === 0);

The statement navigator.platform indicates ‘Win16’ on user’s computer that’s running Windows NT. Which of the following is true?

    navigator.platform is supposed to show ‘Win16’ on Windows NT.
    The userAgent property reflects the correct operating system.
    The property can be modified.
    navigator.platform shows the operating system for which the browser was compiled for.
    The browser version is outdated.

How can GUIDs/UUIDs be created in JavaScript?

    GUIDs/UUIDs cannot be created in JavaScript.
    There is no specific method to create GUIDs/UUIDs, but it’s possible to generate GUID-like random numbers in JavaScript.
    JavaScript has methods only for generating GUIDs/UUIDs with only capital letters.
    JavaScript has methods for creating and automatically changing GUIDs/UUIDs.

Which of the following is the correct method to use, in order to know the name of both the Object and Object Class in JavaScript?

    toSource()
    valueOf()
    toString()
    getName()

What is the correct way to create a JavaScript array?

    var cars = ["Saab", "Volvo", "BMW"];
    var cars= "Saab", "Volvo", "BMW"
    var cars= 1 = ("Saab"), 2 = ("Volvo"), 3 = ("BMW")
    var cars= (1:"Saab", 2:"Volvo", 3:"BMW")

How do you find the number with the highest value of variable a and b?

    top(a, b)
    Math.max(a, b)
    Math.ceil(a, b)
    Math.highest(a, b)

Select the statement that will return truthy value. Array let a = [1,2,3,4] is defined.
Note: There may be more than one right answer.

    4 in a
    a.indexOf(-1) === 3
    a.length
    a

What will the following code return: Boolean(6 > 5)

    NaN
    false
    true
    1

How do you remove property a from this object?
let a = {a:1, b:2};

    a.a = null;
    a.a = false;
    a.a = 'undefined';
    delete a.a;
    remove a.a;

How does the this keyword work within a JavaScript object literal?

    <script>
var foo = {};
foo.someMethod = function(){
alert(this);
}
</script>

    <script>
someMethod = function(){
alert(this);
}
</script>

    <script>
var foo = {};
someMethod.foo = function(){
alert(this);
}
</script>

    <script>
var foo = {};
someMethod = function(foo){
alert(this);
}
</script>

Which of the following is the best way of retrieving DOM elements using CSS class names?

    var className = ‘someClassName’;
var retrievedElements= [];
var myclass = new RegExp(‘\\b’+className+’\\b’);
var elem = this.getElementsByTagName(‘*’);
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retrievedElements.push(elem[i]);
}

    var className = ‘someClassName’;
var retrievedElements= document.getElementsByClassName(className);

    var className = ‘someClassName’;
var retrievedElements= [];
var elem = this.getElementsByTagName(‘*’);
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (className.indexOf(classes) == 0) retrievedElements.push(elem[i]);
}

    It is not possible to retrieve DOM elements using CSS class names.

What is the correct code snippet to change image source?

    document.getElementById(«imgageId»).src = «newImage.png»;
    document.getElementById(«imgageId»).longdesc = «newImage.png»;
    document.getElementById(«imgageId»).href = «newImage.png»;
    document.getElementById(«imgageId») = «newImage.png»;


When toggling a variable, its cycle must be 0 and 1. When the variable’s active value is 0, the next value should be 1, and when the variable’s active value is 1, the next value should be 0.
Considering the scenario above, which of the following is correct?

    q = (q == 1 ? 1 : 0);
    q = 1 — q;
    q ^= 0;
    q = inv(0);

Given a TextArea element with ID "text", which will disable the resizable property of the TextArea?

    document.getElementById(«text»).style.resize = «none»;
    document.getElementById(«text»).style.resize = «disabled»;
    document.getElementById(«text»).resize = «none»;
    document.getElementById(«text»).resize = «disabled»;

Which method is used to evaluate a string of Java Script code in the context of the specified object?

    ParseObject
    ParseDoule
    Eval
    Efloat

Which of the following will include a JavaScript file in another JavaScript file?
Note: There may be more than one right answer.

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

Suppose you receive url of mp3 from server to play it right away. How would you implement this code snippet?

    var audio = new Audio();
audio.play();

    var audio = new Audio(url);
audio.play();

    var audio = new Audio(url);
audio.load();

    var audio = new Audio();
audio.setAttribute(«href», url);
audio.load();
audio.play();

Which of the following is the correct way to stop setInterval() from calling a function in JavaScript?

    setInterval() returns an interval ID, which can pass to clearInterval() to stop it from calling its designated function.
    Cannot stop the setInterval() from calling its designated function.
    Stopping setInterval() is browser-dependent; some browsers support stopping setInterval(), others don't.
    None of these.

Which of the following statements about the ‘new’ keyword is incorrect?

    It creates a new object.
    It sets the constructor property of the object to ‘Object’.
    It prevents any user-defined function from being called as a constructor.
    It executes a constructor function.

How can you calculate the number of arguments received by the function?

    Using arguments.length
    Using args.length.
    Using count(arguments)
    Can not be determined

Which of the following statements are true regarding "window.onload" and "<body onload=""/>"?

    There is no difference between «window.onload» and «<body onload=»»/>», and there is no general preference between the two, as far as best practices is concerned.
    «window.onload» and «<body onload=»»/>» are functionally equivalent, but «<body onload=»»/>» is preferred because it combines the JavaScript code with the HTML markup.
    «window.onload» and «<body onload=»»/>» are functionally equivalent, but «window.onload» is preferred because it separates the JavaScript code from the HTML markup.
    None of the above.

The following codes are for comparing equality operators "==" and "===" in JavaScript. Which of the following are the correct results?
Note: There may be more than one right answer.

    var a = «12» + «3»;
var b = «123»;
return (a === b);
result: true

    var a = [1,2,3];
var b = [1,2,3];
return (a == b);
result: false

    var a = { x: 1, y: 2 };
var b = { x: 1, y: 2 };
return (a === b);
result: true

    var a = new String(«123»);
var b = «123»;
return (a === b);
result: true

    var a = { x: 1, y: 2 };
var b = { x: 1, y: 2 };
return (a == b);
result: true

Which of the following statements are correct about null and undefined?

    Undefined indicates that a variable has not been assigned a value. Null can be assigned to a variable as a representation of no value.
    Both undefined and null indicate that a variable has not been assigned a value.
    Null is a primitive value used when a variable has not been assigned a value. Undefined is a primitive value that represents an empty or non-existent reference.
    None of these.

Which of the following will include a CSS style sheet in page, after an event has occurred?

    document.write(<link rel=»stylesheet» type=»text/css» href=»somestyle.css» />);
    document.createStyleSheet(‘somestyle.css’);
    var styles = «@import url(‘somestyle.css ‘);»;
var newSS = document.createElement(‘link’);
newSS.rel = ‘stylesheet’;
newSS.href = ‘data:text/css,’ + escape(styles);
    None of these.

Suppose you have a circle element of SVG element. How do you draw a black border with width 10px for this circle element?

    circle.setAttribute( “stroke”, “#000000”);
circle.setAttribute( “stroke-width”, “10”);
    circle.setAttribute( “border-color”, “#000000”);
circle.setAttribute( “border-width”, “10”);
    circle.setAttribute( “border”, “#000000; 10”);
    circle.setAttribute( “stroke”, “#000000 10”);

What is the correct format for adding comments to a JSON file?

    /* comment */
    <!— comment —>
    <? comment ?>
    Comments aren’t allowed inside JSON files.

Which operator creates a new object from the specified object type?

    obj
    create
    new
    None of the above

Which of the following variable examples is/are undefined?

    var a;
    var a = “undefined”;
    var a = undefined;
    All of the above

How many type(s) of storage HTML5 supports?

    1
    2
    3
    4

Which of the following code snippets sets cookie correctly?

    document.cookie = «username=John;password=John#1»;
    document.cookie = «username:John;password:John#1»;
    document.cookie(«username=John;password=John#1»);
    document.cookie = «username=John password=John#1»;

Which of the following code snippets sets the cookies which will expire when the browser is closed down?

    var cookie_date = new Date ( );
cookie_date.setTime ( cookie_date.getTime() — 1 );
document.cookie = «username=John;password=John#1;expires=» + cookie_date.toGMTString();

    document.cookie = «username=John;password=John#1»;

    var cookie_date = new Date ( );
cookie_date.setTime ( cookie_date.getTime() + 1000 );
document.cookie = «username=John;password=John#1;expires=» + cookie_date.toGMTString();

    document.cookie = «username=John;password=John#1;expires=0»;

Imagine you have canvas which has image in its content. How to capture HTML Canvas as image?

    var canvas = document.getElementById(«canvasID»);
var url = canvas.toDataURL(«image/png»);
document.write(‘<img src=»‘+url+'»/>’);

    var canvas = document.getElementById(«canvasID»);
var context = canvas .getContext(«2d»);
var imgData=ctx.getImageData(10,10,50,50);
document.write(imgData);

    var canvas = document.getElementById(«canvasID»);
var context = canvas .getContext(«2d»);
var img=document.getElementById(«someImageId»);
context.drawImage(img,0,0);

    It is not possible.

Suppose you have several pages in different locations and need to implement messaging between them. How would you solve security issues?

    Not to add any event listeners for message events. This is a completely foolproof way to avoid security problems.
    Always verify the sender’s identity using the origin and possibly source properties, always verify the syntax of the received message.
    use postMessage method in the following form
friendPage.postMessage(«someMessage», *);
    use listener method in the following form
function receiveMessage(event) {
if (event.origin == senderURL) {
return;
}
// do whatever you want
}
window.addEventListener(«message», receiveMessage, false);

What is the event that fires when the form element textarea loses the focus?

    Onclick
    Ondbclick
    Onfocus
    Onblur

Which of the following can be used to handle the user clicking on a node?
Note: There may be more than one right answer.

    node.addEventListener( “click”, myFunction, false)
    node.addEventListener( “onclick”, myFunction, false)
    node.onclick = myFunction
    node.attachEvent( “onclick”, myFunction)

What will following code print on browser console?
var foo = function foo() {
console.log(foo === foo);
};
foo();

    true
    false
    nothing
    It will raise an exception.

What command skips the rest of a case statement?

    return
    exit
    continue
    break

What method can’t be used with a window object?

    open
    read
    write
    close

How can you detect the client’s browser name?

    client.navName
    browser.appName
    navigator.appName
    None of these

Which of the following is/are the correct way to redirect to a URL in javascript?
Note: There may be more than one right answer.

    document.href= ‘http://www.foobar.com’;
    window.location.assign (“http://www.foobar.com”)
    window.location = ‘http://www.foobar.com’;
    navigator.location = ‘http://www.foobar.com’;

Which of the following way is the best to check browser support for localStorage and sessionStorage?

    if(typeof(Storage)!==”undefined”) {
// Yes! localStorage and sessionStorage support:
// Some code…..
}
else {
// Sorry! No web storage support..
}

    if(sessionStorage!==”undefined”) {
// Yes! localStorage and sessionStorage support:
// Some code…..
}
else {
// Sorry! No web storage support..
}

    if(typeof(localStorage)!==null && typeof(sessionStorage)!==null ) {
// Yes! localStorage and sessionStorage support:
// Some code…..
}
else {
// Sorry! No web storage support..
}

    if(localStorage)!==”undefined”) {
// Yes! localStorage and sessionStorage support:
// Some code…..
}
else {
// Sorry! No web storage support..
}

For the following html element, which is the correct method to change the font size to 25px using javascript?
< p id = “foo”>Lorem Ipsum</ p >

    document.getElementById(“foo”).setFontSize = “25px”;
    document.getElementById(“foo”).style.FontSize = “25px”;
    document.getElementById(“foo”).fontSize = “25px”;
    document.getElementById(“foo”).style(“font-size = 25px”);

Which Window method is used to call a function or evaluate an expression ar specified intervals?

    setInterval()
    repeat()
    setTimeout()

Which of following statements is incorrect regarding localStorage and sessionStorage?

    localStorage — stores data with no expiration date
    sessionStorage — stores data for one session
    The data stored with session Storage is deleted when the user closes the browser window.
    The data stored with localStorage will not be deleted when the browser is closed, and will be available the next day, week, or year.
    None of above

Which of the following methods is used to get the current location of a user?

    getUserPosition()
    getCurrentPosition()
    getPosition()
    None of above

Suppose you have a following Worker. How do you stop this Worker from the main page?
var w = new Worker(“”workers.js””);

    w.terminate();
    w = null;
    w.close();
    w.postMessage(“stop”);

Which of the following statements is incorrect regarding HTML5 Web Worker?

    A web worker is a JavaScript that runs in the background.
    It runs independently of other scripts, without affecting the performance of the page
    The data from the web worker is stored in event.source
    postMessage() method — which is used to posts a message back to the HTML page.

Which of the following statements is incorrect regarding HTML5 Geolocation?

    The HTML5 Geolocation is used to get the geographical position of a user and much more accurate for devices with GPS.
    watchPosition() method of Geolocation object — returns the current position of the user and continues to return updated position as the user moves
    The getCurrentPosition() method returns an object if it is successful.
    The position is always available without the user permission.

What is the output of the following code?
var foo = 123e5;
var bar = 10;
var foobar = foo + bar; alert(foobar)

    12300010
    1230000010
    123e510
    133

Having an array object var arr = new Array(), what is the best way to add a new item to the end of an array?

    arr.push(«New Item»)
    arr[arr.length] = «New Item»
    arr.unshift(«New Item»)
    arr.append(«New Item»)

What is the correct JavaScript syntax to change the content of next HTML element?
<p id="sample">This is a sample text.</p>

    document.getElement(“p”).innerHTML = “Hello World!”;
    #sample.innerHTML = “Hello World!”;
    document.getElementById(“sample”).innerHTML = “Hello World!”;
    document.getElementByName(“p”).innerHTML = “Hello World!”;

Which of the following code snippets deletes cookie correctly?

    var mydate = new Date();
mydate.setTime(mydate.getTime() — 1);
document.cookie = «username=; expires=» + mydate.toGMTString();
    document.cookie = null;
    document.cookie = «username=John;password=John#1»;
    var mydate = new Date();
mydate.setTime(mydate.getTime() + 1000000);
document.cookie = «username=; expires=» + mydate .toGMTString();

What is not true about anonymous functions?

    anonymous functions are created at runtime.
    anonymous functions don’t have a name.
    anonymous functions can not return any value.
    All variables and functions defined within the anonymous function aren’t available to the code outside of it.

Which of the following is the correct method to update the content of an HTML element ‘p’ with id = ‘foo’?

    document.getElementById(«foo»).innerHTML = «some text»;
    document.getElementById(«foo»).HTML = «some text»;
    document.getElementById(«foo»).text = «some text»;
    document.getElement(«foo»).innerHTML = «some text»;

Which of the following is an incorrect way of instantiating a date?

    new Date(dateString)
    new Date()
    new Date(seconds)
    new Date(year, month, day, hours, minutes, seconds, milliseconds)

Which of the following is a client side object?

    Database
    FileUpLoad
    Client
    Cursor

How do you locate the first X in a string variable named txt?

    txt.find(‘X’);
    txt.locate(‘X’);
    txt.indexOf(‘X’);
    txt.countTo(‘X’);

How to write an IF statement for executing some code if var «my_id» is NOT equal to 10?

    if (my_id<>10)
    if my_id =! 10 then
    if my_id <>10
    if (my_id != 10)

Evaluate the following expression: ~-(2 + "2")

    undefined
    SyntaxError
    21
    -22

What is the actual way to remove a property from an object?

    by setting property to undefined
    by deleting the property using delete operator
    by setting property to null
    You can not delete an individual property from an object.

Which of the following determines the type of a given object?

    variable
    typeof
    string
    object

What is the correct JavaScript syntax to change the content of the HTML element with id "header"?

    document.getElementById("header").innerHTML = "Updated Header!";
    #header.innerHTML =  "Updated Header!";
    $header.innerHTML =  "Updated Header!";
    document.getElement("p").innerHTML = "Updated Header!";

What does a "for...in" loop do?

    It iterates over the enumerable properties an object, in arbitrary order
    It iterates over the enumerable properties an string, in arbitrary order
    It iterates over the enumerable properties an integer, in arbitrary order
    It iterates over the enumerable properties an function, in arbitrary order

Why do we programmers use node.js

    Node.js is a client-side software system where Programmers can customize jQuery code library.
    Node.js is a server-side software system where Programmers can write server-side network applications in.
    Node.js is a client-side software system where Programmers use this plugin to create video playing website like Youtube without FFmpeg and FFmpegx.
    Node.js is a server-side software system, programmers use Node.js to debug javascript erros automatically when a website visitor visits the website.

What will be returned if we call f(1);?
const b = [1, 2, 3];
const f = (a, ...b) => a + b;

    7
    1
    6
    Some error

Javascript JS0N data manipulation- How can you access first, last name properties in data object using the following snippet?
 var data={"users":[
        {
            "firstName":"Ali",
            "lastName":"Rehman",
            "birthday": {
                "month":"January",
                "day":20,
                "year":1983
            }
        }      
]}

    document.write(data.users.firstName);
    document.getElementByld(«placeholder»).innerHTML=data.users.firstName;
    document.getElementById(«placeholder»).innerHTHL=data.users[0].firstName + » » +
data.users[0].lastName+»—«+ data.users[0].birthday.month
    document.getElementById(«placeholder»).innerHTML=data .users[0].firstName + » » + data.users[0]

What are valid states of the created Promise?
Note: There may be more than one right answer

    pending
    fulfilled
    initializing
    rejected

Select options which create object type variables:
Note: There may be more than one right answer.

    let a = »;
    let a = {};
    let a = [];
    let a = new String(‘a’);
    let a = null;

How you can check Left mouse button click property?
document.addEventListener("mousedown", buttonpropertys, false);

    function buttonpropertys(e) {
    if (e.button == 1) {
//write some code lines
}

    function buttonpropertys(e) {
    if (e.button == 2) {
//write some code lines
}

    function buttonpropertys(e) {
    if (e.button == 3) {
//write some code lines
}

    function buttonpropertys(e) {
    if (e.button == 4) {
//write some code lines
}

    function buttonpropertys(e) {
    if (e.button == 0) {
//write some code lines
}

What options are types of declarations in JavaScript?
Note: There may be more than one right answer.

    var: Declares a variable
    let: Declares a block scope local variable
    const: Declares a read-only named constant
    None of the above

 Which of the following is the correct way to append a value to an array in JavaScript?

    arr[arr.length+1]= value
    arr[arr.length]= value
    arr[arr.length-1]= value
    arr[arr.length*1]= value

Cookies are a plain text data record with the following  variable-length fields?
Note: There may be more than one right answer.

    Secure
    Domain
    Package
    Media
    Navigator

Which event handlers can be used to create hover effect on HTML element?

    onhoverstart and onhoverend
    onmouseover and onmouseout
    onhover and onout
    mouseenter and mouseleave

Which statement is True for Behavioral design patterns?

    Behavioral design patterns are all about the composition of objects and relationships among them
    Behavioral design patterns focus on the interdependency and communication between objects
    Behavioral design patterns deal with various mechanisms of object creation
    Behavioral design patterns patterns look at optimized or more controlled mechanisms of object creation

Which statement is True for Structural design patterns?

    Structural design patterns patterns look at optimized or more controlled mechanisms of object creation
    Structural design patterns are all about the composition of objects and relationships among them
    Structural design patterns deal with various mechanisms of object creation
    Structural design patterns deal with various mechanisms and more controlled mechanisms of object creation

What will be logged to the console? console.log([0,0,0].fill(l,1)

    RangeError
    SyntaxError
    EvalError
    [0, 1,1]
    [1,1,1]
    [1,0, 0]
    [0,1,0]

What is the value of "n1" and "n2" after executing the following code?
var str = "Finding foo in Foo and Bar";
var n1 = str.search("Foo");
var n2 = str.search(/Foo/i);

    nl = 15, n2 = 15
    nl = 15, n2 = 8
    nl = 8, n2 = 8

After the following JavaScript code is run which of the following is true?
var a = [‘apple’, ‘banana’, ‘coconut’]
var b = a
var c = a.slice()
a.push(‘date’)

    b = [‘apple’, ‘banana’, ‘coconut’, ‘date’] and c = [‘apple’, ‘banana’, ‘coconut’, ‘date’]
    b = [‘apple’, ‘banana’, ‘coconut’, ‘date’] and c = [‘apple’, ‘banana’, ‘coconut’]
    b = [‘apple’, ‘banana’, ‘coconut»] and c = [‘apple’, ‘banana’, ‘coconut’, ‘date’]
    b = [‘apple’, ‘banana’, ‘coconut»] and c = [‘apple’, ‘banana’, ‘coconut»]

How would you change the date to one week later assuming myDate is a date object?

    myDate.chgDate(7);
    myDate.setDate(myDate. getDate()+7);
    myDate.setDate(+7);
    myDate.chgDate(myDate.getDate()+7);

What will be the value of "mystring" variable when the following code is executed?
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop();
var mystring = fruits.join(" * ");

    Banana * Orange * Apple
    Banana * Orange * Apple * Mango
    Orange * Apple * Mango
    mystring will be empty

.What is the super function in the class context?

    It’s used to make super variable, which is available in all class scope
    It’s used to call parent class’ constructor
    It’s called before class’ constructor to initiate starting properties and values
    It’s used in classes to enable ‘this.’ usage

What's true about numbers in JavaScript? (choose all that apply)
Note: There may be more than one right answer.

    There is no such type as integer
    There are positive and negative infinity numbers
    (Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2) will return false
    Number.parselnt() can be used to return integer value of the number
    All of these

    Which of the following is used in JavaScript to insert special characters?

    &
    +
    -
    %
    None of the above

Which of the following is not a JavaScript datatype?

    Function
    Boolean
    Number
    String

Is it possible using JavaScript, without 3rd party libraries,  to select DOM elements with such selector: #question > option

    No. It requires jQuery
    Yes
    No. It requires SizzleJs
    This is CSS selector and has nothing with JavaScript

How do you round the number 3.14, to the nearest integer?

    Math.round(3.14)
    round(3.14)
    rnd(3.14)
    Math.rnd(3.14)

Arrow function expression has a shorter syntax than a function expression and does not bind its own as follow?

    arguments, proptype
    arguments, class
    arguments, super
    proptype, object

Which function will return 10 when called like this: f(10);
Note: There may be more than one right answer.

    const f = (…f) => f;
    const f = (…f) => f.reduce(f => f);
    function f() {
return arguments;
}
    const f = f => f;

How can you remove all of an Element’s children from the DOM?

    function remove( element ) {
if ( element ) element.parentNode.removeChild( element );
}

    function empty( element ) {
    while ( element.firstChild )
remove( element.firstChild );
}

    var listItems = document.getElementsByTagName(‘li’);
    remove(listItems[0]);

    function empty( element ) {
    while ( element.firstChild )
remove(firstChild );
}

Which of the following are structural patterns? (choose all that apply)
Note: There may be more than one right answer.

    State
    Observer
    Composite
    Adapter
    Bridge

Select all correct statements about Object.prototype

    Property attributes are writable
    Property attributes are enumerable
    Property attributes are configurable
    Property attributes are readable

Which JavaScript class represents regular expressions?

    RegExpObj
    RegExp
    RegExpClass
    StringExp

How can you convert a comma separated string variable txt into an array?

    txtArray = txt.indexOf(',');
    txtArray = txt.split(',');
    txtArray = txt.trim(',');
    txtArray = txt.substring(',');

What is TypeError?

    It's a human-friendly string with description about unexpected variable type used
    It's an object with message parameter
    It's instance of Error which has the name of TypeError and message property with human-friendly message
    It's instance of TypeError which has some own methods to get human-friendly error message and has name of TypeError

What value is returned when a Confirm box is cancelled?

    true
    false
    'cancel'
    'undo'

A property is the object oriented equivalent of:

    a function
    an if statement
    a variable
    a reserved word

What's true about the document object in any environment? (choose all that apply)
Note: There may be more than one right answer.

    It's always defined and available to use
    The document object can be used to load new URL in the browser
    The document object can be used to get an element from DOM
    The document object has all active DOM elements in its prototype for quick access

Which of the following Popup Boxes have support in JavaScript?

    Alert Box
    Confirm Box
    Prompt Box
    All of the above

Select the existing event handler for DOM elements.

    onDrag
    onClick
    close
    onload

A property of myobj is defined using:

    property myobj x
    myobj.x
    myobj property x
    var x propertyOf myobj

JavaScript Тест Upwork 2019{jcomments off}