I would start by creating a formal definition of the function that you want and then proving for correctness each of the implementations.
For exampleConsider the following axiomatic definition:
$$replaceAt: string * \mathbb Z *char \to string$$
$$\forall s:string . ( \forall i \in 0.. len(s)-1~.~replaceAt(s,i,`x`)[i] = `x` )$$$$\forall c:char . ( \forall i \in \mathbb Z~.~replaceAt(``,i,c) = `` )$$
$$\forall s:string . ( \forall i,j \in 0..len(s)-1 . i \neq j \implies replaceAt(s,i,`x`)[j] = s[j] )$$$$\forall c:char . (\forall s:string . ( \forall i \in 0.. len(s)-1~.~replaceAt(s,i,c)[i] = c ))$$
$$\forall s:string . ( \forall i \in \mathbb Z . i \geq len(s) \implies replaceAt(s,i,`x`) = s )$$$$\forall c:char . (\forall s:string . ( \forall i \in 0.. len(s)-1~.~len(replaceAt(s,i,c)) = len(s) ))$$
$$\forall c:char .(\forall s:string . ( \forall i,j \in 0..len(s)-1 . i \neq j \implies replaceAt(s,i,c)[j] = s[j] ))$$
$$\forall c:char .(\forall s:string . ( \forall i \in \mathbb Z . i \geq len(s) \implies replaceAt(s,i,c) = s ))$$
If you can prove the correctness of each implementation to the definitionthese axioms I'd say they're equivalent. At the moment your C implementation is not even a function. Your Javascript function takes a string and not a char. None of them are defined for indexes greater than your input.
I don't think comparing implementation to implementation makes sense as there are lot of assumptionsdifferences in the implementation models of each language.