question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'foo in bar' evaluates to null if bar is a native JavaScript Object

See original GitHub issue

This looks wrong to me, @chochos:

dynamic {
    dynamic obj = dynamic [];
    Boolean bool = 0 in obj;
    print(bool);
}

Prints <null>.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
quintessecommented, Oct 12, 2016

And nobody likes my idea to just create two toplevel functions to create empty objects and arrays? Because I find the whole business of dynamic vs dynamic [] somewhat cryptic (and highly JS-specific, if we ever implement dynamic for the Java backend creating empty objects and arrays makes little sense). Using functions would make it very explicit what you’re doing.

0reactions
quintessecommented, Oct 12, 2016

JS is not the only dynamic language …

I doubt that those other languages will map perfectly to JS’ idea of hashmaps and arrays, so if we would ever support them as a backend we’d probably have to come up with other conventions for their constructs. To me this seems like one of these ad-hoc decisions just to make things work. Especially when creating a special syntax that only works for specific backend(s).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Check if a value is an object in JavaScript - Stack Overflow
The Object constructor creates an object wrapper for the given value. If the value is null or undefined, it will create and return...
Read more >
Optional chaining (?.) - JavaScript - MDN Web Docs
The optional chaining ( ?. ) operator accesses an object's property or calls a function. If the object is undefined or null ,...
Read more >
Object destructuring best practice in Javascript | by Crunch Tech
The object destructuring assignment syntax gives us a third way to access object properties: const { foo } = myObj // 'bar'
Read more >
The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, ... var object = {foo: "bar", foo: "baz"}; ) or a duplicate...
Read more >
The Best JavaScript Examples - freeCodeCamp
Argument Example The arguments object is an array-like object (in that ... "foo" + "bar" // concatenates the strings and returns "foobar".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found