Revision fdf1c96f-639b-4e2b-9704-a8533d4b4b9b - Stack Overflow

This is a fairly simple question, but I can't seem to find an example online. I've read up on objects and functions (i.e. <a href="http://stackoverflow.com/questions/8902687/javascript-storing-function-in-object-bad-practice">here</a>), but can't seem to find an example of a function within an object that accepts parameters. 

In JavaScript, we can create an object, a nested object, and a method defined by a function:

 var testObject = {
 nestedObject : {
 isNumber : function(number) { return !isNaN(number) };
 }
 }

How can I call my function with a specific parameter? Is the following correct?

 testObject[nestedObject].isNumber(number)

Thanks!

AltStyle によって変換されたページ (->オリジナル) /