My goal is to determine the amount of time it takes for the caret to move from the beginning to the end of a string.
Explanation:
Consider this string ""
in the following code snippet: http://jsfiddle.net/RFuQ3/
If you place the caret before the first quote and press the right arrow key ►, you will need to press 3 times to reach after the second quote (instead of 2 times for an empty string).
The most common way to calculate the length of a string is using <string>.length
.
However, in this case, it returns 2.
Another method, as discussed here JavaScript Get real length of a string (without entities), also gives a result of 2.
How can I achieve a result of 1?
1-I have come up with an idea to input the string into a text field and then use a while
loop with a try{setCaret}catch(){}
function.
2-This is simply for entertainment purposes