Asked  7 Months ago    Answers:  5   Viewed   64 times

Below, you can see the output from these two logs. The first clearly shows the full object with the property I'm trying to access, but on the very next line of code, I can't access it with config.col_id_3 (see the "undefined" in the screenshot?). Can anyone explain this? I can get access to every other property except field_id_4 as well.


This is what these lines print in Console

Console output



The output of console.log(anObject) is misleading; the state of the object displayed is only resolved when you expand the Object tree displayed in the console, by clicking on >. It is not the state of the object when you console.log'd the object.

Instead, try console.log(Object.keys(config)), or even console.log(JSON.stringify(config)) and you will see the keys, or the state of the object at the time you called console.log.

You will (usually) find the keys are being added after your console.log call.

Tuesday, June 1, 2021
answered 7 Months ago

In the default browser on Android 2.3.3 (and presumably from then on) you can simply use the built in javascript console:

  • open the browser
  • go to your webpage
  • type about:debug in the address bar and hit enter
  • you'll see a section for debug options appear if you go into the browser app's settings
  • tick "Show JavaScript Console" if not already enabled
  • refresh your webpage

At the top, you'll see a bar labeled "JavaScript Console".

Tuesday, July 13, 2021
answered 5 Months ago

Great query. We have tried to hard to get this done. The only working solution I found

get value by using self.valueForKey("aVariable_")

set value using self.setValue("New Value", forKey: "aVariable_")

Hope that helps. Possible solution without altering super class.

Friday, July 30, 2021
answered 5 Months ago

This is an artifact of the way the Javascript console works when you log an object. The log doesn't contain a copy of all the object properties, it just contains a reference to the object. When you click on the disclosure triangle, it then looks up all the properties and displays them.

In this case, at the time you call console.log(e), there's a DOM element in the currentTarget property. But sometime later, that property is reset to null for some reason. When you expand the event object, that's what you see.

A simple example that demonstrates this is:

var foo = { };
for (var i = 0; i < 100; i++) {
    foo['longprefix' + i] = i;
foo.longprefix90 = 'abc';

When you view the object in the console, you'll see that foo.longprefix90 contains "abc", even though it contained 90 at the time that console.log(foo) was called.

The demonstration needs to use an object with lots of properties. When it's logging, it shows the first few properties that fit in the console, so those are in the early snapshot. Only properties after that display this anomalous behavior.

Sunday, August 8, 2021
answered 4 Months ago

I'll guess that your HTML is something like this

<div my-directive editable="{{someScopeProperty}}"...></div>

and that you are calling console.log() in your link function. When the link function runs, interpolated attributes are not defined yet (you need to use $observe or $watch to asynchronously get the interpolated value), so you'll get undefined if you attempt to log the value. Soon after, the value gets defined, and Chrome seems to automatically update the value (which is really a reference, I think) in the console where you logged the full object (not just the individual value).

Monday, August 30, 2021
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :