Q:

What does (-’string’.length) do in Javascript

I'm having a hard time following this concept.  The point of the function is for it to take 2 parameters and test if the target parameter is the end of the str parameter.
So end('Sebastion', 'ion') would return true and end('Sebastion', 'eon') would return false
I found this solution and don't understand what the -target.length is doing and how matching that to target is testing the parameters.  
I'm fairly new to JavaScript so if someone has any insight on how this is working that would be great.
function end(str, target) {
  return (str.substr(-target.length) === target);
}

A:

Let's evaluate str.substr(-target.length).
Following the rules of precedence, we need to evaluate -target.length first.
Again following the rules of precedence, we evaluate target.length first.  We do this because "Member Access" is near the top of the precedence table.  This evaluates to 3 in your example.
Negate that, to get -3.
Okay, so now we need to evaluate the result of str.substr(-3):
The JavaScript substr function has this in this documentation on MDN:

start: Location at which to begin extracting characters. If a negative number is given, it is treated as strLength + start where strLength is the length of the string (for example, if start is -3 it is treated as strLength - 3.)
If start is negative, substr() uses it as a character index from the end of the string. If start is negative and abs(start) is larger than the length of the string, substr() uses 0 as the start index. Note: the described handling of negative values of the start argument is not supported by Microsoft JScript.

So it takes the final 3 characters of the source string.

