one way to do it:
function select(selector){
return {where:function(where){
//do whatever you're doing with where and selector
return {and:function(whatever){/*do something with whatever*/}}
}}
}
you can add additional functions to each returned object
Jsfiddle: http://jsfiddle.net/markasoftware/78aSa/1/
if you are trying to make it so that and and where are on the same object, do this instead:
function select(selector){
var selectObj=this;
this.where=function(where){
//do whatever with where and select
//now add the and method
selectObj.and=function(whatever){
//do stuff with selector, where, and whatever
}
return selectObj
}
return selectObj;
}
jsfiddle of this one: http://jsfiddle.net/markasoftware/34BYa/
method chaining, read a bit here: kwilson.me.uk/blog/simple-javascript-method-chaining