Tag Archives: String in JavaScript

Check whether the value is undefined or not in JavaScript using typeof

The following code snippet demonstrates how to check undefined or empty value in JavaScript.
In the below code we will use the typeof operator because typeof always returns a string, and doesn’t generate an error if the variable doesn’t exist. For it we can write a function like as as shown below: Continue reading Check whether the value is undefined or not in JavaScript using typeof

How to remove leading and trailing spaces from a string in JavaScript.

JavaScript
Some browsers gives an error when you use the function like trim() with string in JavaScript as ‘unknown function or property’. For it we can use a regular expression that will replace all extra spaces at the start and end of the string with an empty string. Continue reading How to remove leading and trailing spaces from a string in JavaScript.