のため申し訳ありませんあなたはそれに接続されているすべてのプロパティを取得するためにObject.getOwnPropertyNamesでwindow
のプロトタイプチェーンを通過する必要があります。のみに結果をフィルタリング
私にとって
var target = window,
result = [];
do {
result = result.concat(Object.getOwnPropertyNames(target));
} while(target = Object.getPrototypeOf(target))
result = result
//Filter out properties such as "onclick" which are null by default
.filter(function(r){ return window[r] != null; })
//Optional: filter out those whose type is not "object"
.filter(function(r){ return typeof window[r] === 'object'; });
(この非常にページ内クロームV50)は、その長さ24は
["SpeechSynthesisUtterance", "PresentationAvailability", "BeforeInstallPromptEvent", "CanvasRenderingContext2D", "SVGRadialGradientElement", "SVGLinearGradientElement", "SVGFEGaussianBlurElement", "SVGFEDistantLightElement", "SVGAnimatedTransformList"]
を返されるが、それらのすべてが機能の代わりに、オブジェクトとされているプロパティ名を含めますしたがって、x+''
には"function SpeechSynthesisUtterance() { [native code] }"
のようなものがありますので、探しているものが含まれているかどうかはわかりません。
私にとって
//Get the string representation of the global object
.map(function(r){ return window[r] + ''; });
を追加し、['[object Math]', ...]
のような文字列表現を含むリストを取得するには、それらの一つは、24の長さを有していた:'[object SpeechSynthesis]'
'Object.keys()'を取得あなたは鍵です。キーをループし、それぞれの値を取得します: 'window [key]'。 – Blender
実際には、すべてのオブジェクトタイプの完全なリポジトリはありません。たとえば、キャンバス要素を作成し、['getImageData']を呼び出すことで、[' ImageData'](https://developer.mozilla.org/en-US/docs/Web/API/ImageData)のインスタンスしか取得できません。 (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData)または['createImageData'](https://developer.mozilla.org/en-US/docs/Web/ API/CanvasRenderingContext2D/createImageData)。 –
'Object.keys'は継承されない値だけを返します。ウィンドウは、継承された(プロトタイプの)値を持つことができるオブジェクトです。すべてのキーを取得するには、 'for(i in window)'のようなものを使ってオブジェクトをループする必要があります。また、すべてのオブジェクトが 'window'オブジェクトの子であるとは限りません。 –