valueOf()  Object  instance method getterS2C Home  « Globals « Object « valueOf()


Returns the primitive value of an object.

  • Automatically invoked when an object is called and a primitive value is expected.
  • The Object.valueOf() method is inherited by all Object descendants.
  • Unless overridden by a custom object valueOf() returns [object Object].


Signature Description
anObject.valueOf()Returns the primitive value of an object.




The code below creates an object and displays it.

// Create an object.
anObject = new Object();
alert(anObject.valueOf() + ' anObject is an instance of Object.');

Press the button below to action the above code:

Related Tutorials

JavaScript Basic Tutorials - Lesson 7 - Objects

go to home page Homepage go to top of page Top