check whether the variable is string in js code example
Example 1: js test if string
if (typeof string === 'string') { /* code */ };
Example 2: check data type in javascript
typeof("string"); //string
typeof(123); //number
if (typeof string === 'string') { /* code */ };
typeof("string"); //string
typeof(123); //number