reverse() পদ্ধতিটি জায়গায় একটি অ্যারে কে অন্য অ্যারের বিপরীত করে। প্রথম অ্যারের উপাদানটি সর্বশেষ হয় এবং শেষ অ্যারে উপাদানটি প্রথম হয়। এটা মূল অ্যারের পরিবর্তন।
1 2 3 4 5 6 7 8 9 10 11 12 13 |
const array1 = ['one', 'two', 'three']; console.log('array1:', array1); // expected output: "array1:" Array ["one", "two", "three"] const reversed = array1.reverse(); console.log('reversed:', reversed); // expected output: "reversed:" Array ["three", "two", "one"] // Careful: reverse is destructive -- it changes the original array. console.log('array1:', array1); // expected output: "array1:" Array ["three", "two", "one"] |
এখানে মুল Array ছিলো array1 = [“one”, “two”, “three”] কিন্তু রিভার্স করার পর হলো array1 (reversed) = [“three”, “two”, “one”] এমন কি যখন আমরা আবার মুল Array টা […]