Home » JavaScript » JavaScript Functions » Question
  1. If you have a function f and an object o, you can define a method named m of o with
    1. obj=fun.meth;
    2. obj=fun;
    3. obj.meth=meth.fun;
    4. obj.meth=fun;
    5. None of these
Correct Option: D

A method is nothing more than a JavaScript function that is stored in a property of an object. If you have a function fun and an object obj, you can define a method named meth of obj with the following line:
obj.meth = fun;



Your comments will be displayed only after manual approval.