Writing null-safe code to set form values
(document.getElementById(arr[i].id) || 0).value = arr[i].value;



In this code there is a pointless assignment when the element is not found.
In this case, the 0 gets wrapped into a temporary object,
and the assignment will work, but it will be pointless,
it's result will be thrown away.
This assignment is merely a side effect of the shortcut,
it has no purpose of its own.

Every operation in a program should be intentional, purposeful, and this shortcut violates that. As such, I consider this a dirty hack. Don't use it.



When in doubt,
go for the more intuitive and readable solution.
The first example in your post is slightly longer,
but it's simple and clear: there's no question about what will happen.

The second way,
although shorter,
may not be obvious for everyone.

Keep in mind that code is read far more times than it’s written.
It's better to favor a technique that's clear and easy to understand to something "clever" but potentially confusing / obscure. 



Additional excellent recommendation by @GameAlchemist, verbatim:


  1) for optimisation purposes, the if is faster. and more importantly 2) a piece of code should be as much self-documenting as possible. Even if (element) is better written if (element != null) (which makes obvious the defensive check against getElementById returning null)