function CarCateCollection(name) { this.name = name; this.length = 0; this.add = addCarCate; return this; } function addCarCate(object) { this.length++; this[this.length] = object } function CarCateNode(id,name) { this.id = id; this.name = name; return this; } function extractCarCateChildrenOf(node,arr) { var children = new CarCateCollection(node); var currentIndex = 1; while (currentIndex <= arr.length) { //arr[currentIndex].id.startWith(node) && if (arr[currentIndex].id.substring(0,node.length)==node && arr[currentIndex].id.length==(node.length+3) ) { children.add(arr[currentIndex]) } currentIndex++ } return children; } carcates=new CarCateCollection("C"); carcates.add(new CarCateNode("C003","½Î³µ")) carcates.add(new CarCateNode("C002","ÖаÍ")) carcates.add(new CarCateNode("C001","´ó°Í"))