![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/clinic.corals.io/node_modules/collect.js/docs/api/ |
# `replaceRecursive()` This method works like replace, but it will recurse into arrays and apply the same replacement process to the inner values: ```js const collection = collect([ 'Matip', 'van Dijk', [ 'Mané', 'Firmino', 'Salah', ], ]); const replaced = collection.replaceRecursive({ 0: 'Gomez', 2: { 1: 'Origi' }, }); replaced.all(); // { // 0: 'Gomez', // 1: 'van Dijk', // 2: { 0: 'Mané', 1: 'Origi', 2: 'Salah' }, // } ``` [View source on GitHub](https://github.com/ecrmnn/collect.js/blob/master/src/methods/replaceRecursive.js)