Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 4 What does the following code do? Number.prototype.toCurrencyString =

ID: 3574566 • Letter: Q

Question

  

Question 4

What does the following code do?
Number.prototype.toCurrencyString = function () {
    return "$" + this.toFixed(2);

}

Adds a cascading property to the Number object.

Adds a cascading method to the Number object.

Returns a Number object.

Creates a method that can be called from a variable that holds an integer or floating-point number.

Question 8

Code example 11-1

var invoice = {
    getSalesTax: function( subtotal ) {
        return ( subtotal * this.taxRate );
    },
    getTotal: function ( subtotal, salesTax ) {
        return subtotal + salesTax;
    },
    taxRate: 0.0875
};

(Refer to code example 11-1.) This code creates an object of the

object type

Invoice type

Object type

invoice type

  

Question 9

Code example 11-3

var Employee = function(firstName, lastName) {
    this.firstName = firstName;
    this.lastName = lastName;
};

Employee.prototype.getFullName = function() {
    return this.firstName + " " + this.lastName;
};

(Refer to code example 11-3.) This code creates an Employee object type that contains

2 methods

1 constructor and 1 method

1 constructor, 1 method, and 2 properties

1 constructor and 2 properties

  

Question 15

Code example 13-1

var evt = {
    attach: function(node, eventName, func) {
        if (node.addEventListener) {
            node.addEventListener(eventName, func);
        } else if (node.attachEvent) {
            node.attachEvent("on" + eventName, func);
        }
    },
    detach: function(node, eventName, func) {
        if (node.removeEventListener) {
            node.removeEventListener(eventName, func);
        } else if (node.detachEvent) {
            node.detachEvent("on" + eventName, func);
        }
    },
    preventDefault: function(e) {
        e = e || window.event;
        if ( e.preventDefault ) { e.preventDefault(); }
        else { e.returnValue = false; }
    }
};

(Refer to code example 13-1.) This is the code for a cross-browser compatible library for working with events. In the code for the attach method, the if clause provides for modern browsers and the else if clause provides for older IE browsers. This shows that older browsers require the use of

the addEventListener method of a node object and no prefix for the event name

the attachEvent method of a node object and the no prefix for the event name

the attachEvent method of a node object and the prefix “on” for the event name

the addEventListener method of a node object and the prefix “on” for the event name


Question 17

When creating a timer, the delay or ____________________ is specified in milliseconds.

Question 18

Assume that you have an object of the Object type named employee. Assume also that this object only has two properties named firstName and lastName. What does the following code do?
employee.streetAddress = "123 Main Street";

It causes an error because no property named streetAddress exists for the employee object.

It adds an event named streetAddress to the employee object.

It adds a method named streetAddress to the employee object.

It adds a property named streetAddress to the employee object.

  

Question 20

Code example 13-1

var evt = {
    attach: function(node, eventName, func) {
        if (node.addEventListener) {
            node.addEventListener(eventName, func);
        } else if (node.attachEvent) {
            node.attachEvent("on" + eventName, func);
        }
    },
    detach: function(node, eventName, func) {
        if (node.removeEventListener) {
            node.removeEventListener(eventName, func);
        } else if (node.detachEvent) {
            node.detachEvent("on" + eventName, func);
        }
    },
    preventDefault: function(e) {
        e = e || window.event;
        if ( e.preventDefault ) { e.preventDefault(); }
        else { e.returnValue = false; }
    }
};

(Refer to code example 13-1.) This is the code for a cross-browser compatible library for working with events. It contains

Two functions and one property.

Two methods and one property

Three functions

Three methods

a.

Adds a cascading property to the Number object.

b.

Adds a cascading method to the Number object.

c.

Returns a Number object.

d.

Creates a method that can be called from a variable that holds an integer or floating-point number.

Explanation / Answer

question 17.The another command used is sleep command.Even sleep command is given in milliseconds

question18.option D

It adds a property named streetAddress to employee object

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote