  Assuming that the shallow-decaying phase in the early X-ray lightcurves of
gamma-ray bursts (GRBs) is attributed to the dipole radiations (DRs) of a
newborn magnetar, we present a comparative analysis for the magnetars born in
death of massive stars and merger of compact binaries with long and short GRB
(lGRB and sGRB) data observed with the {\em Swift} mission. We show that the
typical braking index ($n$) of the magnetars is $\sim 3$ in the sGRB sample,
and it is $\sim 4$ for the magnetars in the lGRB sample. Selecting a sub-sample
of the magnetars whose spin-down is dominated by DRs ($n\lesssim 3$) and
adopting a universal radiation efficiency of $0.3$, we find that the typical
magnetic field strength ($B_p$) is $10^{16}$ G {\em vs.} $10^{15}$ G and the
typical initial period ($P_0$) is $\sim 20$ ms {\em vs.} $2$ ms for the
magnetars in the sGRBs {\em vs.} lGRBs. They follow the same relation between
$P_0$ and the isotropic GRB energy as $ P_0\propto E_{\rm jet}^{-0.4}$. We also
extend our comparison analysis to superluminous supernovae (SLSNe) and stable
pulsars. Our results show that a magnetar born in merger of compact stars tends
to have a stronger $B_p$ and a longer $P_0$ by about one order of magnitude
than that born in collapse of massive stars. Its spin-down is dominated by the
magnetic DRs as old pulsars, being due to its strong magnetic field strength,
whereas the early spin-down of magnetars born in massive star collapse is
governed by both the DRs and gravitational wave (GW) emission. A magnetar with
a faster rotation speed should power a more energetic jet, being independent of
its formation approach.
