Ali Rahbari (2018-08-21T17:54:54.000Z)
rahbari at gmail.com (2018-08-21T17:58:51.498Z)
while it's possible to use let keyword in for loop parentheses, it's not possible to use it in if parentheses. There are two use cases for this: *1- if (let a = b()) a.c();* this can be done using optional chaining which is proposed: b()?.c(); *2- if (let a = b()) c(a);* this or more sophisticated patterns can't be done in any way other than: let a = b(); if (a) c(a); beside more line of codes the problem here is *a* is defined outside of if scope.
rahbari at gmail.com (2018-08-21T17:58:05.899Z)
while it's possible to use let keyword in for loop parentheses, it's not possible to use it in if parentheses. There are two use cases for this: *1- if (let a = b()) a.c();* this can be done using optional chaining which is proposed: b()?.c(); *2- if (let a = b()) c(a);* this or more sophisticated patterns can't be done in any way other than: let a = b(); if (a) c(a); the problem here beside more line of codes, is *a *is defined outside of if scope.
rahbari at gmail.com (2018-08-21T17:57:47.843Z)
while it's possible to use let keyword in for loop parentheses, it's not possible to use it in if parentheses. There are two use cases for this: *1- if (let a = b()) a.c();* this can be done using optional chaining which is proposed: b()?.c(); *2- if (let a = b()) c(a);* this or more sophisticated patterns can't be done in any way other than: let a = b(); if (a) c(a); the problem here beside more line of codes, is *a *is defined outside of if scope.