Yes. Not only does Google look at JavaScript redirects the same as 301s, but Mariya Moeva, a Search Quality Team member at Google, also confirmed at SMX West 2017 that Google looks primarily at the DOM rather than the source code of a page.
Therefore, dynamically inserted <a> elements would be weighted the same as if they were located within the source code.