Let's say I have bellow object :
var obj = {
name:'Jone',
age:'23',
height:200,
weight:400,
}
I want this :
var obj1 = {
name:'Jone',
age:'23'
}
var obj2 = {
height:200,
weight:400
}
Really what I'm looking for is obj.splice('age') meaning that split this object into two object , starting from age as the key.
I know I can loop and do it the hard way, but is there any equivalent easy nice way ?
Also, if there is any Angular2ish way(a hidden utility maybe ? ), would be even better.
EDIT : I don't exactly know what's inside the object , I just know my key is in there .
What I really am doing is I want to loop around an object , but I have an start point and i don't want to loop through all , I want to be able to cut that object and just start the loop from where I need.
Object.keys(obj).map( function( value , index ) {
// I'm just looping here to do some stuff , which is not related to the question here.
} );
Obviously I'm looping over all the keys of this object , but I want to start from age .
I hope this is clear .
EDIT ; I know this is getting a little bit out of the board , but in Angular2 , we have a formModel and we can have multiple controlGroup inside it , I want to basically be able to find the first controlGroup that is invalid , that's it .