newspaint

Documenting Problems That Were Difficult To Find The Answer To

Monthly Archives: Jun 2013

Node.JS String Length Undefined

This issue arose using node.js version v0.10.3.

Here’s some example code:

function writeStringLength( str ) {
  console.log( "str = \"" + str + "\"" );
  console.log( "str.length is " + str.length );

  var copy = str;
  console.log( "copy.length is " + copy.length );

  var copyObj = new String( str );
  console.log( "copyObj.length is " + copyObj.length );
}

var now = new Date();
writeStringLength( now.getFullYear() );

This outputs:

user@localhost:/tmp$ /usr/local/node/bin/node /tmp/brokenstring.js
str = "2013"
str.length is undefined
copy.length is undefined
copyObj.length is 4

So – why does JavaScript think the string doesn’t have a defined value for the length property? According to the Node.JS manual entry for the String object “JavaScript distinguishes between String objects and primitive string values”. Conversion of primitive strings to String objects should happen automatically but clearly in this case node.js is unable to determine that the function parameter is a string that needs “boxing” into a string object. By forcing a new String object to be created we can be sure the length property will return a useful value.

Note that the values returned by the Date() object functions causes this problem – perhaps because Node.JS doesn’t know for certain what kind of values these functions returns (could they be from an external library?). Whereas if you try and pass an ordinary string (e.g. “example”) to writeStringLength() then the parameter will, as expected, have a defined length property. Perhaps this is because node.js knows the parameter is an explicitly defined string in this example.

The Rise of the Incompetent Recruiter

Let’s look at the e-mails in my LinkedIn inbox:

Extracts from message one:

Please contact me with regards to your current availability for work. … Should this role not be suitable for you please accept my apologies and by all means pass on my contact details should you know anyone that may be interested.

Message two:

… Please let me know if you know anybody that would be suitable.

Message three:

… Alternatively if you know of anyone in the market you would personally recommend then please let me know.

What do they all have in common? For one thing they expect me to do their job for them: find them a candidate for the role they are seeking to fulfil.

The other thing that seems to happen a lot, now, is that recruiters will catch a single buzz-phrase in my profile and then send me job offers based around that single keyword. Obviously they’ve not looked at the rest of my profile. Obviously they don’t know that I’m hardly suitable for their role and I’m far too over-qualified for it. They also refuse to talk rates in their initial e-mail – and they are almost always seeking to fill a cheap role that nobody who knows what they are talking about will take.

I’m just getting tired of these endless approaches that seem personal – because they use my name, and might say things like “your profile looks of particular interest to myself” – while not actually specifically mentioning any experience in my profile. Further it is annoying they keep pitching me for roles I would never take given their junior salary. Finally it infuriates me they expect me to find a candidate for them.

It’s time we told these incompetent recruiters to stop begging. LinkedIn recruiter approaches are just like all the “homeless” beggars that line up along your daily commute path. It isn’t respectful – certainly not in the technology industry.

I’m not against somebody genuinely approaching me – if they’ve read my profile. If they genuinely have a position they think I could fulfil. If they could genuinely offer me something approaching my current salary. But I’ve only had maybe the one contact that even slightly approached these conditions. The rest: are lazy talentless thieving scum looking for an easy ride to a lucrative skim off your pay packet with absolutely no concern about your welfare.