Given an object obj
, the following two-line statements can be defined:
var obj ={} //this is an object
obj.isShiny = function () {
console.log(this);
return "you bet1";
};
These two lines can be combined into a one-line statement as shown below:
var obj={isShiny : function () {console.log(this);return "you bet1";}};
Similarly, for a function func
with the following two-line statements:
var func = function () {console.log(this)}; //this is a function
func.isShiny = function () {
console.log(this);
return "you bet1";
};
The question arises if it's possible to merge these statements into a single line?