DEV Community

Discussion on: `at` coming soon to ECMAScript

Collapse
 
nicholaschiasson profile image
Nicholas Omer Chiasson

Does this work with positive out of bounds also, kind of like a modulo of the length? Say arr.length is 4 and you tried arr.at(5), does it give you arr[1]? Just curious.

Collapse
 
islamcn profile image
Isla McNeill • Edited

It will give you undefined. That way you're not running yourself in circles.

Collapse
 
yoursunny profile image
Junxiao Shi

Modulo is risky because you get NaN on an empty array.

Collapse
 
laurieontech profile image
Laurie

No. Positive out of bounds is undefined.