Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Depends on what you think by adding ';' in the condition (it's still a syntax error)
But it's possible to check if you can successfully pass a function's result to a variable
Ex:
let stuff = null;
if(stuff = some_function(some, params)) {
// Code
}
I've seen this once but I would not recommend that -
@kimb result have other key too.
Let say message
Then to access message, ain't I again need to do the foo().message ? -
@nihalmurmu if you know that foo() returns true, but it also can return something else, you could do
if(foo() && foo() === true){
// Code
} -
if((result = foo()).status == true)
Should do
Result needs to be defined beforehand, though -
drtokky2117y@Drillan767
But usually Foo returns Bar, I see that everywhere all the time, also returns Baz, my bad.. -
Why the hell do you want to write that?
Why dont you just write:
result = foo();
if (result && result.status) {
//...
}
Or to be sure
result = foo();
if ('result' in result && result.status) {
//...
}
Is it possible to write something like in JavaScript
if( result = foo(); result.status == true)
{
//Code goes here
}
question
javascript