Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page >

継承

JavaScriptでは、prototypeキーワードによって、あるオブジェクトをほかのオブジェクトから継承することができます。別のオブジェクトから継承するには、次のように、オブジェクトのプロトタイプを、親オブジェクトのプロトタイプと等しくなるように設定します。

MyChildObject.prototype = MyParentObject.prototype;

これにより、親の関数と変数すべてがオブジェクトにコピーされます。

最新のWeb Kitビルドには、prototypeキーワードを通じて既存のDOMオブジェクトに追加する機能も含まれています。継承と比較した場合のこの方法の長所は、メモリ占有量が小さく、関数オーバーロードがしやすいことです。



< Previous PageNext Page >


Last updated: 2007-06-11




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice