The victory was the first for the Islanders at Barclays Center, the Brooklyn arena they will move to for the 2015-16 season.
McDonald had an unassisted goal at 11:32.
Martin Havlat scored for the Devils 8 minutes into the second, and Michael Ryder tied it on a power play 2 minutes into the third. Havlat was stopped by Chad Johnson to seal the shootout win.
The Islanders are preparing to play their final season at Nassau Coliseum.