jsonQ.js
function(target, index, val, clone) {

            if (isNaN(index) && index != "first" && index != "last") {
                error(index + 'is not a valid index.');
                return;
            }

            var type = objType(target),
                length = target.length;

            //to limit index
            var idx = index < 0 || index == "first" ? 0 : index > length || index == "last" ? length : index;


            //if array push
            if (type == 'array') {
                val = clone ? jsonQ.clone(val) : val;
                target.splice(idx, 0, val);
            }

            //if string concatenate , if number add
            else if (type == 'string') {
                target = target.substring(0, idx) + val + target.substring(idx, length);
            }


            return target;

        }
function(target, index, val, clone) {

            if (isNaN(index) && index != "first" && index != "last") {
                error(index + 'is not a valid index.');
                return;
            }

            var type = objType(target),
                length = target.length;

            //to limit index
            var idx = index < 0 || index == "first" ? 0 : index > length || index == "last" ? length : index;


            //if array push
            if (type == 'array') {
                val = clone ? jsonQ.clone(val) : val;
                target.splice(idx, 0, val);
            }

            //if string concatenate , if number add
            else if (type == 'string') {
                target = target.substring(0, idx) + val + target.substring(idx, length);
            }


            return target;

        }
function ( target , index , val , clone ) { if ( isNaN ( index ) && index != "first" && index != "last" ) { error ( index + 'is not a valid index.' ) ; return ; } var type = objType ( target ) , length = target . length ; //to limit index var idx = index < 0 || index == "first" ? 0 : index > length || index == "last" ? length : index ; //if array push if ( type == 'array' ) { val = clone ? jsonQ . clone ( val ) : val ; target . splice ( idx , 0 , val ) ; } //if string concatenate , if number add else if ( type == 'string' ) { target = target . substring ( 0 , idx ) + val + target . substring ( idx , length ) ; } return target ; }
to append at specific index of values of array or string
to append at specific index of values of array or string