You for sure had seen jquery. Has you know jquery allow you to make chaining of method like this:
$('.elements').css({color:'red'}).etc().etc()...
But if you notice, that function returns you a array of object(?):
$(document).ready(function(){
var $elements = $('.c').css({color:'red'});
console.log($elements);
});
(Example, see console to see the result)
Also the $
function does as well:
$(document).ready(function(){
var $elements = $('.c');
console.log($elements);
});
(Example, see console to see the result)
Both returns an array and then can keep chaining. How is that possible? Why can keep chaining when it isn't return just this
(or the object itself)?
I read this post and he could succesfully add plus sign but that was to an existing string cuz he proto the string object.
Its there any way that i could archive that?
UPDATE
I know that it return a jquery object but how can i return my object that contains an array of values and keep chaining with the returned values.
UPDATE 2
What i want to archive
I have this class and i want a method to return an array of my object whenever if the chaining its over
var elements = Enumerable(anArray).Where(function(elements){ return elements != 1 })
Here the chainig has over so it must return the elements that satisfy the condition but i want to keep chaingin i just have to do this:
elements = elements.Where(function(elements){ return elements == 1}).Take(3);
And keep chaining as looooong as I want.