Technology & Me ...

JavaScript Functions Part 2 – Function Expression

Welcome to JavaScript Function series. In part 1, we discussed Function Declaration syntax in JavaScript and few traps associated with it. In this article we will discuss JavaScript Function Expression. Function Expression A function expression has similar syntax as function declaration except that function value is assigned to a variable name. Let’s take a look at an example – var log = function logMessage(message) { console.log(message); } log("This is a function expression"); Once you define a function using this syntax, the function name [logMessage in this case] becomes obsolete and the function can be called only using the assigned variable…

JavaScript Functions Part 1 – Function Declaration

JavaScript is one of the most hated programming language amongst the developer community. There is infinite number of articles on the internet which highlights bad parts of the language. But the fact is that it’s still the most powerful language, thanks to the web. Though primarily introduced as client side programming language, JavaScript found its footprint on the server side as well with framework like node.js. If you’re not familiar with how JavaScript differs from programming languages like C++, Java and C#, I recommend you to read my article on Top 10 JavaScript traps for C# programmer. Functions are at…

Method Chaining Design Pattern in C# and JavaScript

One of the most commonly used and useful design pattern in programming language is Method Chaining. As the name suggests, it allows you to chain / call multiple functions on the same object consecutively, without any need to specify object name during each method call. This pattern is heavily used in JavaScript libraries like jQuery, AngularJS and in Language Integrated Query [LINQ] feature of C#. In the first part of this article, we will cover how this pattern is implemented in jQuery and C# LINQ. The code snippet presented in the article will help you to understand how this pattern…

Top 10 JavaScript traps for a C# developer

If you are an experienced C# developer, coming into JavaScript world for application development, you will end up making few common mistakes. However some of the mistakes you would make are due to the basic differences between any strongly typed language [C#, Java etc.] and a dynamically typed language [JavaScript, Python etc]. Although dynamic feature was added to C# version 4.0, its initial design was based on static typing. Note, I am primarily a .Net developer and have experience of developing web applications using JavaScript, and I admit that I made these mistakes when I started learning JavaScript. I spent…

How to avoid race condition in C#?

Classes in System.Threading namespace and Task Parallel Library [TPL]  introduced in .Net framework 4.0 helps application developer write concurrent, multithreaded, parallel and asynchronous program. Yes I know; I have used quite a few heavy words here, which are often confusing and difficult to differentiate.  So let’s understand the difference between these terminologies first and then we will drill into race condition and thread / task synchronization. Concurrent – A concurrent system is a one where computation can make progress without waiting for all other computation to complete [extracted from Wikipedia]. However, it’s a generalized term as it does not specify…

1 of 11
12345