top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to add function as a property in a JavaScript object?

+1 vote
75 views
How to add function as a property in a JavaScript object?
posted Mar 28, 2014 by Divya Bharti

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes

The below code will explains how to add function as a property in a JavaScript object

var vehicle = new Object();
vehicle.name = 'swift';
vehicle.color='red';
vehicle.getName = function() 
{ 
return vehicle.name;
}
answer Apr 2, 2014 by Simranjeet Singh
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...