javascript array slice time complexity