I have question about native javascript calling.
i have a class:
x = function(arr) { this.arr = arr; return this; }
x.prototype.toArray = function() {
return this.arr;
};
x.prototype.test = function() { alert('but i m object too!'); };
when i calling:
var test = new x(['a','b','c']);
alert(test[0]);
alert(test.test());
need to get result 'a' and 'but i m object too!' dialogs.
I want to use this feature as syntax sugar like uses jquery in core when returning DOM Elements after using selector as array. How to implement that?
UPDATE:
Thank for answer, but i need proofs in jquery code blob on github.
$('selector')[0]