Edit in JSFiddle

 var obj1 = {
     name: "obj1",
 }
 
 function returnName() {
            return this + ":" + this.name;
        }

 obj1.f = returnName; //add method to object
 document.write(obj1.f()); //[object Object]:obj1