You seem to be mistaking a function's prototype property with the internal prototype of an object.
A relevant quote from the book Eloquent Javascript:
It is important to note the distinction between the way a prototype is associated with a constructor (through its prototype property) and the way objects have a prototype (which can be retrieved with Object.getPrototypeOf). The actual prototype of a constructor is Function.prototype since constructors are functions. Its prototype property will be the prototype of instances created through it but is not its own prototype.
What this means in the context of your code sample:
$scope.test.prototype.push = function(data) {
return data;
};
Here you've added a push function to the prototype property of the $scope.test function, which will be present on the prototype of objects created by using this test function as a constructor function (with the new keyword).
$scope.test, however, remains an empty function, which has no .push() method, resulting in the error. If you want to add a push method to every function, you could use Function.prototype (note that Function is the constructor with which new functions are created), but I'm not sure where are we going with this.
testbecomes accessible from objects that you create usingtestas a constructor function, not from the function object itself, unless you did$scope.test.prototype.push(1);, which would be strange. You can add thepushfunction directly to the$scope.testfunction if you wish, but I'm not sure what you're after in the end.var a = new $scope.test.push(1);and if so the convention would be to name Test from capital letter