In fact, the propertyIsEnumerable() method can be used to show that it isn't, itself,
Good practice is for all built-in methods to be non-enumerable and any user-defined meth-
ods to be made enumerable. This is so that all the built-in methods don't keep showing up
when looking at an object's methods, but user-defined methods are easy to spot.
The Object constructor function prototype has a toString() method that's made
available to all objects; however, different objects implement the method in different ways.
Calling it on an array object will return each value in a comma-separated string:
Calling it on a primitive number value will return a string containing that number:
2..toString; // remember 2 dot operators for integers!
Note: Primitive Object Wrappers
The number, string, and Boolean primitive types that we met way back in
Chapter 2 have their own corresponding constructor functions: Number ,
String , and Boolean respectively.
Rather bizarrely, though, these constructors don't produce primitive values:
new Number(2); // the return value looks like a
Search WWH ::