Asynchronous JS – JavaScript for C# developers

Below content is an excerpt from my book – “JavaScript for C# developers“.   Consider the below code snippet, which has just 3 statements and seems to be simple but it is worth analysing it to understand how javascript works with respect to execution of asynchronous code.  During the execution phase, JavaScript engine starts executing your code from first statement till last …

Function Scope in JavaScript – JavaScript for C# developers

Below content is an excerpt from my book – “JavaScript for C# developers“.   Scope in javascript works completely different from how it works in C#.  In javascript, we have both block scope and function scope. However, the predominant scope used in javascript is function scope till ES5. We would discuss later in this chapter about the rules which javascript engine uses to decide whether …

Arrow functions in JavaScript – JavaScript for C# developers

Below content is an excerpt from my book – “JavaScript for C# developers“.  Starting from ES6, there is a new way to declare a function in javascript – Arrow functions.  This is similar to the function expression in ES5 but has a concise syntax. Despite the fact that both constructs – functions in ES5 and arrow functions from ES6 – perform a task …

How value of ‘this’ is evaluated in JavaScript – Part 2

Below content is an excerpt from my book – “JavaScript for C# developers“.  In the last blog post, we’ve discussed how the value of ‘this’ is evaluated in below scenarios Invocation of function through object Invocation of function directly (without any object) If you’ve not read that blog post, I recommend you to read that blog post before proceeding further. …

How value of ‘this’ is evaluated in JavaScript – Part 1

Below content is an excerpt from my book – “JavaScript for C# developers“.   As with many things in javascript, the evaluation of the value of ‘this’ keyword in JavaScript is completely different from how it is done in C#. Before discussing about how JS engine evaluates the value of ‘this’ keyword in javascript, let us revisit how ‘this’ works in C#. Consider the below C# code snippet, where we …

$ symbol in jQuery (and in javascript)

Before discussing about the functionality of ‘$’ in jQuery, let us take a look at what it( $ sign) means with respect to JavaScript, as a language. With respect to javaScript, $ symbol is just a valid identifier. Consider the following code snippet $ = 5; console.log($); The above code snippet would just print number 5 in the console. So, …

var in C#

Using var keyword, you can declare and initialize variable of any type.  By the initialization value, the type of variable (created using ‘var’ keyword) would be decided. Let us see an example var varString = “Hello World”; var varInt = 32; Console.WriteLine(varString.GetType()); // Will print System.String Console.WriteLine(varInt.GetType()); // Will print System.Int32 In the above code snippet, we are declaring couple of variables varString, varInt and assigning string value (“Hello World”) , integer value(32) respectively. When you …

Difference between fields and properties in C#

If you are a beginner, you might get confused between a field and a property. You can store value using either a field or a property and retrieve the value back. You can even protect both fields and properties using access modifiers such as private or protected. So you might wonder, why we need to have property when you can …

Difference between string in String in C#

If you are new to C#, you might wonder what’s the difference between String(with capital S) and string (with small s) in C#. string(with small s) is a keyword in C# which represents the System.String type in Common Type System whereas the String (with capital S) is the shorthand notation for System.String.  Consider the following code snippet where we declare …

Why we use HTML helpers in ASP.Net MVC instead of normal ASP.Net Controls?

If you are from ASP.Net Web Forms background, you might’ve wondered why we are using HTML helpers instead of ASP.Net controls in ASP.Net MVC? It is easy to use ASP.Net controls such as asp:TextBox – isn’t it? Because ASP.Net WebForms controls remember what you typed in the form and you can easily get the property by using .Text in C# …