August 7, 2012

Data type conversion

JavaScript is a dynamic type language, this means that you can whenever change the type of variables by assigning a different value which is of a different type. This aspect of the language is good because it gives to the programmer the liberty to do everything he wants, but sometimes this liberty can  bring some confusion when working with variables of a specific type and treating them as another data type. This can happen when reading the value of an HTML input and treat it as a number for example, it is needed to convert the desired variable to the desired data type.

July 25, 2012

Asynchronous programming

When I discovered the Node.js environment I was pleasantly surprised meeting JavaScript on the server side. I was reading the documentation on its API and encountered the strange for me, at that time, concept of synchronous and asynchronous execution of different operations in this JavaScript implementation. I knew about AJAX and how to work with it, but could not imagine how to create an application based only on the concept of waiting for a response and then make another action.

July 15, 2012

Event-driven programming

Event-driven programming is an application architecture technique which suppose the existence of a main loop which is composed from two sections: event detection and event handling. This technique is very handy for programming graphical user interface, however it can lead to errors if event handlers change some values in global context and if their activity is not supervised enough in interaction with the rest of the application or other event handlers.

July 13, 2012

Prototypal Inheritance

JavaScript has a different behavior from other modern programming languages, but it can simulate some aspects of them, for example classical inheritance. During the study and the use in practice of the language, I have not needed to use inheritance, I only knew that it exists, but I have not used it until I started to write some more complex and specific code. Then I needed a mechanism to reuse some parts of code that were repeated more than two or three times, which could be used in the future and could make the comprehension of the code more difficult.

July 11, 2012

Good advices

JavaScript is sometimes too liberal and gives too much liberty in writing code, he does not ask you to specify variables types or to end lines with semicolon. Sometimes this is good, but sometimes this is bad, especially when your code grows in size and it becomes difficult to observe the evolution of variables when the code is executed. So, it is good to follow some simple rules.

July 9, 2012

Hello JS

A good application written in JavaScript is not only the beautiful user interface or the useful functional, it is also a well formed code which is hidden behind the decoration that the user can see. By well formed code I mean an easy to understand structure of the code, appropriate and suggestive names for variables and functions, comments explaining what the code does or with some information what is in the "ToDo" list. This is a very useful skill to be able to write such code if you want to develop further your application, if you want to show somebody your code or if you work in team, everybody who sees your code has to understand what you wrote there.

First post. About

Let the show begin, I start blogging. So, in this blog I will try to describe various aspects of JavaScript and its interaction with other technologies like HTML and CSS. Also, I will focus my attention on Node.js environment, event-driven programming and asynchronous I/O. My goal is to show how simple is to write JavaScript code and how entertaining it can be.

I will try to write short and simple to understand posts, may be not so short like this one. I hope that this stuff will be useful for someone. Read and enjoy this little corner of the internet.