in Education by
How can we make methods available on all objects? (a) Object.add(methods) (b) Object.methods(add) (c) Object.add.methods(…) (d) Object.prototype I have been asked this question in final exam. The query is from Augmentation of Classes in chapter Classes and Modules in JavaScript of JavaScript Select the correct answer from above options JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Right choice is (d) Object.prototype Easiest explanation: It is possible to add methods to Object.prototype, making them available on all objects. This is not recommended, however, because prior to ECMAScript5, there is no way to make these add-on methods non enumerable, and if you add properties to Object.prototype, those properties will be reported by all for/in loops.

Related questions

0 votes
    How many default number methods are available in JavaScript? (a) 5 (b) 6 (c) 7 (d) 8 This ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
0 votes
    How many Node object methods are available? (a) 18 (b) 19 (c) 20 (d) 21 I had been ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
0 votes
    Which of these methods can randomize all elements in a list? (a) rand() (b) randomize() (c) ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which design pattern represents a way to access all the objects in a collection? (a) Iterator pattern (b ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    How can we delete all files in a directory? (a) Files.delete(path) (b) Files.deleteDir() (c) ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    All methods must be implemented of an interface. (a) True (b) False This question was addressed to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
0 votes
    How can we filter lines based on content? (a) lines.filter() (b) filter(lines) (c) lines. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
...