Test string as a literal and as an object

JavaScript typeof operator returns a string that identifies the data type of an expression. It is used to get the data type (returns a string) of its operand. The operand can be either a literal or a data structure such as a variable, a function, or an object. The operator returns the data type. There are six possible values that typeof returns: object, boolean, function, number, string, and undefined . example
var strLtr = "This is a string literal"; var strObj = new String("This is a string object"); alert(isLtrObj(strLtr)); alert(isLtrObj(strObj)); function isLtrObj(str) { return typeof(str) == 'string' str instanceof String; }
JavaScript Literals A literal is a notation for representing a fixed value in source code. Almost all programming languages have notations for atomic values such as integers, floating-point numbers, and strings, and usually for booleans and characters; some also have notations for elements of enumerated types and compound values such as arrays, records, and objects. JavaScript Objects An object is an unordered list of primitive data types (and sometimes reference data types) that is stored as a series of name-value pairs. Each item in the list is called a property (functions are called methods).