Skip to content
Advertisement

Tag: string

Smart way to truncate long strings

Does anyone have a more sophisticated solution/library for truncating strings with JavaScript and putting an ellipsis on the end, than the obvious one: Answer Essentially, you check the length of the given string. If it’s longer than a given length n, clip it to length n (substr or slice) and add html entity … (…) to the clipped string. Such

What is the difference between ‘ and ” in JavaScript?

I saw this question and I am wondering about the same thing in JavaScript. If you use the character ‘ or the character ” when making strings in JavaScript, the application seems to behave the same. So what is the difference between these two characters? The only advantage I have seen in using ‘ to build strings is that I

Advertisement