You're approaching it from the wrong angle. You can write nice reliable JavaScript code if you understand the philosophy, if you know the pitfalls and what to pay attention to.

You can't write JavaScript code the way you write C# code. It's like writing SQL-code with a lot of loops and IF-statements. Just because you can doesn't mean you should.

The problem is that it's hard to find good resources on writing good JavaScript code.

You should definitely watch the Douglas Crockford videos on JavaScript:

I frequently hear people say that Crockford's JavaScript: The Good Parts is the best book about writing good JavaScript code.