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.

Unable to call object properties that are functions

See original GitHub issue

The following code produces a parsing error when run on the playground

ask {
  const sum = fun(a, b) {
      a + b
  }
  
  const diff = fun(a, b) {
      a - b
  }
  
  const myMath = { sum, diff }
   
  myMath.sum(2, 2)
}

It works fine, when myMath is destructured first:

const s = myMath.sum
s(2,2)

Used expression (myMath.sum(2, 2)) should be translated into

<call
  args={
    <list>
      {2}
      {2}
    </list>
  }
>
  <call
    name="at"
    args={
      <list>
        <ref name="myMath" />
        {"sum"}
      </list>
    }
  />
</call>

Note that call in AskJSX can accept either the name property in args or function expression in its first child.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
lukasz-xfaangcommented, May 18, 2021

Ack. I will try to reply tomorrow.

0reactions
pkarwcommented, Jun 17, 2021

@lukasz-xfaang i’ve stuck on this 😦 I really need your help @lukasz-xfaang @czerwinskilukasz1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to call object properties from functions in JavaScript
Easy fix: There is really no reason to call y:(height/2)-(batHeight/2),. since you are defining batHeight two lines above it.
Read more >
Working with objects - JavaScript - MDN Web Docs - Mozilla
An object is a collection of properties, and a property is an association between a name (or key) and a value. A property's...
Read more >
Function object, NFE - The Modern JavaScript Tutorial
In JavaScript, functions are objects. A good way to imagine functions is as callable “action objects”. We can not only call them, but...
Read more >
How to call a Function inside an Object in JavaScript
You can call a function inside an object by declaring the function as a property on the object and invoking it, e.g. obj.sum(2,...
Read more >
emscripten::val - Unable to call function inside property of ...
I have Global JavaScript object structured like below, ` foo Object > gee property >> nee() function >> zee() function ` I used...
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