Aug 31
I’ve just returned from a really nice weekend on this lovely hotel. Bar services could be a little better and it’s not the easiest place to find, but the hotel is just great! Highly recommended if you’re looking for a nice place to say and relax for a couple of days. Here are some pics […]
Read the rest of this entry »
Aug 28
In yesterday’s post about the in operator, Bertrand mentioned that it would be interesting to show the differences between the in operator and the hasOwnProperty method defined on the Object “type”. As always, he’s right and I guess that I should write up a small post explaining the difference between these two. Both of them […]
Read the rest of this entry »
Aug 27
I guess that you’ve written code like this in the past: var user = document.getElementById("name"); var msg = "Hello, " + user.value; alert(msg); I can tell you that I’ve written several lines of code that resemble the previous snippet in the past. However, you should avoid it whenever possible. The main problem with it is […]
Read the rest of this entry »
Aug 26
There is no excerpt because this is a protected post.
Read the rest of this entry »
Aug 26
Since I’ve started blogging about JavaScript, I thought that it would be ok to share with you one of the most embarrassing bugs I’ve introduce in a code base. Now, when I look back, I do find it funny, but I can tell you that I didn’t laugh about it at the time. The code […]
Read the rest of this entry »
Aug 26
Suppose you’ve got a function and you expect it to receive some optional parameters. In these cases, you’d like those optional parameters to be initialized with a predefined value. Can we do that in Javascript? Yes, we can and all we need is to use the || operator. The following snippet should make this point […]
Read the rest of this entry »
Aug 25
There are still lots of guys that don’t know that JavaScript has the === operator. The truth is that you should always use this operator instead of relying on the == operator. Btw, and since we’re talking about comparison operators, there is also a !== operator that should be used when you need to test […]
Read the rest of this entry »
Aug 24
There is no excerpt because this is a protected post.
Read the rest of this entry »
Aug 24
In the previous posts of the series, we’ve started looking at functions. Today we’ll pick up where we left and we’re going to take a deep look at function invocation. I guess that first thing we should understand is what happens when we call a function. Invoking function X leads to the suspension of the […]
Read the rest of this entry »
Aug 24
In a previous post, we’ve already met an easy way of creating objects through literal objects (which I personally prefer to call anonymous objects). Unfortunately, there were some shortcomings to that strategy: things didn’t work quite well when we needed to add methods that should be used for specific types of objects. Today we’re going […]
Read the rest of this entry »
Aug 21
Today I’ve managed to do another walk. This time, it was a really short one, from Ribeiro Frio to Balcões. I’ve took some pictures and I’ve uploaded them to facebook.
Read the rest of this entry »
Aug 20
I was looking at my settings on msmvps.com and I’ve notice that I’ve hit the 1000 posts mark. Honestly, I never expected to reach that mark (nor was it an objective), but it seems like it happened…
Read the rest of this entry »
Aug 20
When I first started working with Javascript, I was a little surprise to know that you’ve got two “basic” types in Javascript: there are simple types and objects. Simple types are numbers, strings, bools, null and undefined. Everything else is an object. Objects are associated with two interesting features in Javascript: unlike most OO languages, […]
Read the rest of this entry »
Aug 19
In the previous posts, we’ve met several helper methods which simplify the code needed to perform remote out-of-band requests. In this post, we’ll be introducing the all mighty $.ajax method. This method is used by all the other methods we’ve seen until now and gives you complete control over the request. Currently, you’re supposed to […]
Read the rest of this entry »
Aug 19
Impressive video that I’ve found through Alberto’s blog.
Read the rest of this entry »
Aug 19
Deferred script loading is a technique which can be used to reduce the initial loading time of any page. The idea is to load only the basic JavaScript code that is necessary for the initial loading operations of the page and then perform additional downloads for features that the user *might* use after initial rendering. […]
Read the rest of this entry »
Aug 19
In this post we’ll keep looking at JQuery’s helper methods for remote calls and we’ll see how we can use the get and post functions for performing HTTP GET and POST requests. Both functions (notice that these are utility functions and not JQuery object methods!) expect several parameters: $.get( url, [data], [callback], [type] ) $.post( […]
Read the rest of this entry »
Aug 17
Today marks the beginning of using JQuery for handling AJAX requests. This is going to be a short post and we’ll be talking about the load method. The load method is able to perform get or post requests to replace the contents of the elements contained in the wrapped set with the response returned from […]
Read the rest of this entry »
Aug 14
In the previous posts, we’ve met several methods which run some predefined animations. Instead of trying to add methods for all possible animations, JQuery has decided to introduce a helper function which you can reuse for animating several css properties (notice that you can only animate properties which expect numeric values). Currently, there are two […]
Read the rest of this entry »
Aug 14
[Update: thanks to Howard, I’ve updated the typo regarding global functions.] In a previous post, we’ve talked about scopes. Today we’ll be talking about execution contexts. Every line of JS code you write runs in a certain execution context. If you’re coming to JS from an object oriented language, then you should recognize this concept. […]
Read the rest of this entry »
Aug 13
There is no excerpt because this is a protected post.
Read the rest of this entry »
Aug 12
In this post we’ll keep looking at the animations and we’ll see how to add fading effects to an element. Unlike showing and hiding, which affect several css properties of the element, fading will only affect the opacity (alpha filters if you’re running IE) and display of an element. Currently, JQuery offers 3 methods: fadeIn, […]
Read the rest of this entry »
Aug 10
This is the last post of the day on JQuery and we’re going to talk about extending objects with the extend utility function. The idea is simple: how can you add properties from an object to another and get a new object? For instance, suppose you’ve got these two anonymous objects: var student = { […]
Read the rest of this entry »
Aug 10
The map utility function can be used to translate all the elements contained in the array into other set of items. You’ll find this method useful when you need to transform a collection of items A into items. The function expects two parameters: an array of items that is going to be translated; a callback […]
Read the rest of this entry »
Aug 10
There is no excerpt because this is a protected post.
Read the rest of this entry »
Aug 10
In the last post we’ve seen how to get all the items that comply with a specific filter. In this post, we’re going to see how to see if an item is in an array. The easiest way to do that is to use the inArray function. Take a look at the following snippet: var […]
Read the rest of this entry »
Aug 07
In this post, we’re going to look at the each utility function. This function expects two parameters: an object which is going to be enumerated and a callback function reference which is going to be called for each item in the enumerated set. It’s important to understand that this is different from the each jQuery […]
Read the rest of this entry »
Aug 07
There is no excerpt because this is a protected post.
Read the rest of this entry »