The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

peterd (6) [Avatar] Offline
#1
Also, JSHint complains that Listing 1.3 isnt entirely kosher.

For example, `profile` is never really defined (but I assumed it was meant to be `var profile = connections[i];`)

Also, wondering if `var i = 0;` should be moved out of the for loop and even storing the value of `connections.length` in to a separate variable. Or something roughly like the following:

IN.API.Connections("me").result(function(connections) {
var ul = document.getElementById('connections'),
i = 0,
len = connections.length,
profile,
fullName,
li;

for (; i < len; i += 1) {
profile = connections[i];
fullName = [profile.firstName, profile.lastName].join(' ');
li = document.createElement('li');
li.innerHTML = fullName;
ul.appendChild(li);
}
});
benvinegar (68) [Avatar] Offline
#2
Re: Listing 1.3 vs JSHint
Thanks for the tip. I think I mentioned this in another post, but we actually killed this example in favor of another one.