Mike Mike - 1 year ago 72
Javascript Question

reading Javascript object

I have the following object in JavaScript that I capture from the console window:

action: "android.intent.action.SEND"
clipItems: Array[1]
component: "ComponentInfo{com.reunion.family/com.reunion.family.MainActivity}"
extras: Object
android.intent.extra.SUBJECT: "Adam Harris"
android.intent.extra.TEXT: "http://www.adamwadeharris.com/setup-remote-debugging-phonegap/"
share_screenshot_as_stream: "content://com.android.chrome.FileProvider/images/screenshot/1472164245526-1842859201.jpg"
__proto__: —
flags: 318767105
type: "text/plain"
__proto__: —

I can read the outer fields just find and the clipItems object without a issue. However the extras object I'm having a issue reading the "android.intent.extra.TEXT" and " android.intent.extra.SUBJECT" fields.
the object that I wrote out to the console is called: intent


so I tried:


but keep gettng a error message :

Error in Success callbackId: IntentPlugin1397752597 : TypeError: Cannot read property 'intent' of undefined

so i must be missing something.

any help would be great.

Answer Source

You can't use . to access a property name that isn't a valid identifier. Since the property name contains . characters, which are used as delimiters between nested properties, you can't use . to access the property itself. You have to use [] to access it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download