Juri Strumpflohner
Juri Strumpflohner Juri is a full stack developer and tech lead with a special passion for the web and frontend development. He creates online videos for Egghead.io, writes articles on his blog and for tech magazines, speaks at conferences and holds training workshops.

The Similarity of C# and JavaScript Syntax

1 min read

I'm currently diving deeply into creating rich JavaScript web applications. You cannot deny that they are now the must have for modern-looking web (2.0) apps. They are rich, user-friendly and provide a desktop-like experience within the browser..without the need to install heavy applications or runtimes. While initially building such apps was a pure pain, emerging JavaScript frameworks and libraries make it really fun and easy. So webdevs out there...if you want to keep up, go and get in touch with JavaScript. It is the language of programming the web :).
Just when coding some JavaScript I noted that the syntax between C# and JavaScript is actually quite similar. Take these examples:

Variables


C#
var x = "some string";
JavaScript
var x = "some string";


Anonymous Object initialization


C#
var x = new {
Name = "Juri",
Surname = "Strumpflohner"
};
JavaScript
var x = {
name: "Juri",
surname: "Strumpflohner"
};


Delegates/Callbacks


C#
var result = SomeFunction(
() => {
//A delegate method performing some work
}
);
JavaScript
var result = someFunction(function (){
//callback / delegate
});
comments powered by Disqus