javascript - Which method is faster and better? -


function tozero1(t) {     return ("" + t).length < 2 ? "0" + ("" + t) : ("" + t); }  function tozero2(t) {     return "00".slice(("" + t).length) + ("" + t); } 

these functions do: "6"-> "06" "11"-> "11" etc.


Comments