-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boolean values are handled as property names #46
Comments
Hey Bart! The
would have the same meaning as simply
For this reason, I currently don't consider including I'm currently working on adding constants to the language (see issue #38), I assume they will be ready to test during this weekend. I think this feature will solve your issue: const options = {
constants: { true: true, false: false }
}
const fn = compileExpression(`messageOpen == true`, options)
fn({ messageOpen: true }) // → true
fn({ messageOpen: false }) // → false
fn({ messageOpen: 1 }) // → false What do you think about this solution? Does it fix your problem? PS: |
Hi Michal, Thanks and congratulations with your final exam results! |
Published on NPM as I expect that a stable v3 release will come soon (after I update the README and write a complete changelog). |
Hello Michal, |
Good to hear! 👍 |
Dear,
I wanted to test whether an object property is
true
.Don't see booleans values mentioned on the readme page, but found an Add booleans pull request.
So I assume this is supported...
However I get the impression that it only works for a boolean as string (
"true"
or"false"
)...Because when I use this expression:
Then it tries to get a property with the name "true" from my object:
I was wondering if you could do something like this in your code: when the property name is "true" or "false", then it is no property but a boolean. So you simply leave it untouched in the expression, without wrapping it with
prop(...)
?P.S. I don't think that "true" or "false" are allowed as property names in JavaScript, when looking at this Stackoverflow discussion. When you click on the Mozilla link in that this discussion you find this:
Additionally, the literals null, true, and false cannot be used as identifiers in ECMAScript.
A JavaScript identifier is a sequence of characters in the code, that identifies a variable, function, or property...
Thanks!!!
Bart
The text was updated successfully, but these errors were encountered: