Re: [JSMentors] Should XmlHttpRequest Response Be HTML or JSON?

2011-09-11 Thread Sergio Cinos
In my opinion, there are several advantages on using JSON and render it client-side - Payload: JSON is way smaller than HTML. Specially important if you are going to be browsed through a 3G connection. - Server optimization: usually, the server can render JSON faster than HTML (not in all cases,

Re: [JSMentors] Re: Diagnosing Sluggishness in IE9 RC?

2011-03-05 Thread Sergio Cinos
What I usually look for in the Profile: - Identify functions with biggest excl. time and try to optimize them - Same for functions that are executed a lot of times - Identify functions with a big difference between total time and excl. time. It usually means that the function is doing something

Re: [JSMentors] Diagnosing Sluggishness in IE9 RC?

2011-03-03 Thread Sergio Cinos
I'll try two things: a) Inspect the Profile output. There is a lot of information there. Probably your answer is hidden somewhere in that info. b) Try to disable big portions of the app to get more information on the problem: is the whole system causing the problems? A specific module? Try

Re: [JSMentors] What are the alternatives to var self = this?

2011-03-03 Thread Sergio Cinos
If I have to choose, I prefer to use 'that' or something more descriptive like 'originalThis'. But the best solution (IMHO) is to write a bind function in Function.prototype that returns another function with a fixed value for 'this'. For example: Function.prototype.bind = function(obj) {

Re: [JSMentors] Re: Today, Web Development Sucks

2011-02-03 Thread Sergio Cinos
2011/2/3 Guillaume Andrieu gh...@taleo-initiative.org: What should I recommend to new employees in my company when they have to learn Javascript, who have to start coding with Javascript without having had any proper formation ? Why do you have people that needs to start coding JavaScript

Re: [JSMentors] JS API Design - Accepting Parameters

2011-01-13 Thread Sergio Cinos
When creating an API, I always try to be as friendly as possible to the 'user' (the programmer using that API). So usually the best option is to support as many type of arguments (object, separate values...) as you can. Also, try to be permissive with the order. For example, if you build a join()

Re: [JSMentors] Prototype

2010-12-29 Thread Sergio Cinos
I would add: To set the prototype of an object, you modify the 'prototype' property of its constructor function. To get access to the prototype you can use myFunction.prototype or myInstance.__proto__. //Constructor function var myFunction = function() { /*...*/ } myFunction.prototype.myProperty