, [] ( ), object, '' , .
- , .
: isString true , ? (?) , , .
It is much more common to ignore the type of a variable and, where it can change, unconditionally convert it to the required type, for example. if you want a string primitive:
function foo(s) {
s = String(s);
...
}
The exception is that functions are overloaded and have different behavior depending on whether a particular argument is a function, an object, or some other. Such overloading is usually not considered a good idea, but many javascript libraries depend on it. In these cases, passing a String object rather than a string primitive can have unexpected consequences.
source
share