JavaScript 对象的基础知识 - 对象的方法的引用

在JavaScript中对象方法的引用是非常简单的。ObjectName.methods()实际上methods()=FunctionName方法实质上是一个函数。

如引用university对象中的showmy()方法,则可使用: document.write (university.showmy())或:document.write(university)如引用math内部对象中cos()的方法

则: with(math) document.write(cos(35)); document.write(cos(80));若不使用with则引用时相对要复杂些: document.write(Math.cos(35)) document.write(math.sin(80))