If we consider this as a variable created by utilizing .serializeArray()
x={"acctType1":"individual","compare_act1":"contains","match_name_act1":"accountName","text_act1":"","acctType2":"individual","compare_act2":"contains","match_name_act2":"accountName","text_act2":"","transType1":"401kContribution","compare_trans1":"contains","match_name_trans1":"description","text_trans1":"","transType2":"401kContribution","compare_trans2":"contains","match_name_trans2":"description","text_trans2":""}
then the total length would be = 16.
by using :
Object.keys(x).length;
Suppose we only want to find the length up to transtype1
, which should be 8 in this scenario - how can we achieve that?
Here's another case :
y={"acctType1":"individual","compare_act1":"contains","match_name_act1":"accountName","text_act1":"","acctType2":"individual","compare_act2":"contains","match_name_act2":"accountName","text_act2":"","acctType3":"individual","compare_act3":"contains","match_name_act3":"accountName","text_act3":"","acctType4":"individual","compare_act4":"contains","match_name_act4":"accountName","text_act4":"","acctType5":"individual","compare_act5":"contains","match_name_act5":"accountName","text_act5":"","transType1":"401kContribution","compare_trans1":"contains","match_name_trans1":"description","text_trans1":"","transType2":"401kContribution","compare_trans2":"contains","match_name_trans2":"description","text_trans2":"","transType3":"401kContribution","compare_trans3":"contains","match_name_trans3":"description","text_trans3":""}
the length of y = 32
however, the length up to transtype1
is 20
Many thanks in advance