What is the best way to restore a new Mac (running Yosemite) to its "unused" state i.e. if you use a new mac to try it out, but have to return it to its owner, how can you make sure that any personal information (Apple ID, emails, web history, Pages Documents etc) on the Mac has been removed. I would like to do something similar to how you can delete all user data on an iPhone i.e. without having to format the disk and re-install the OS. To be clear, I do not want to save anything from the Mac, but purely to restore it to "factory fresh" state.
For the OSX factory reset, backup all your data, then restart your Mac and hold down Command + R key. Use Disk Utility to erase the hard drive. Click on Disk Utility > Continue. Select the main volume and click Unmount then Erase. Quit Disk Utility. Click Reinstall OS X and Continue. Follow the instructions to reinstall Mac OS X.
For IOS, go to Settings/General/Reset and select Erase All Content and Settings