How you will add function as a property in a JavaScript object? Give an example.

  • : 314
  • : 5
    Previous Next

    var man = new Object(); = 'Vikas Ahlawat'; = true;
    man.age = 27;
    man.getName = function() { return;}
    console.log(man.getName()); // Logs 'Vikas Ahlawat'.

    you can suggest other answer in comment box

  • Exam: Java Script Interview QUESTIONS

    Recommended Learning for you

    Subscribe here for free mock test on IAS PCS SSC and other competitive exam. Signup here to get SSC CGL Solution and main exam study material