toSorted, toReversed, with
Në shqip: Metodat e reja pa ndryshim të vargut
ShpjegimiSQ
sort() dhe reverse() e ndryshojnë vargun origjinal. Versionet e reja toSorted(), toReversed(), toSpliced() dhe with() kthejnë një varg të ri — ideale për React.
EnglishEN
sort() and reverse() change the original array. The new versions toSorted(), toReversed(), toSpliced() and with() return a new array — ideal for React.
Si ta mendosh
Si ta rendisësh një kopje të listës pa e prekur origjinalin.
Lexoje në anglisht
Like sorting a copy of the list without touching the original.
Shembull kodijavascript
const notat = [3, 1, 2];
const renditur = notat.toSorted(); // [1, 2, 3]
console.log(notat); // [3, 1, 2] — e paprekur