Skip to content

Instantly share code, notes, and snippets.

@ahmadajmi
Created March 24, 2011 07:41
Show Gist options
  • Save ahmadajmi/884710 to your computer and use it in GitHub Desktop.
Save ahmadajmi/884710 to your computer and use it in GitHub Desktop.
Strings in javascript
var str = new String("foo"); // String Object
typeof str; // return "Object"
typeof str.valueOf(); // return "String"
var str = String("foo"); // Primitive String
typeof str; // return "String"
var str = "foo"; // Primitive String (literal)
typeof str; // return "String"
var str = String(45); // Primitive String also called String Function
typeof str; // return "String"
str; // return "45"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment