You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The optional chaining ?. is a safe way to access nested object properties, even if an intermediate property doesn’t exist. (error.response && error.response.headers && error.response.headers['x-description']) || error.message
using optional chaining it reduces to error.response?.headers?.['x-description'] || error.message
This can also be used to invoke methods on objects, etc
This improves readability as well as simplifies the existing code
Nullish coalescing
Nullish coalescing is an improvement on the || operator where it only checks if an object is null or undefined.
Using the || operator returns false if the object is zero or an empty string which can cause issues in the code when the value is zero but incorrectly treated as false
Thanks @davidjumani, please advise if/when there are more PRs about this issue. Perhaps we can also track them on the issue description using a task list
@davidjumani quick question, how much of vue.js do I need to know in order to work on this issue ? I have worked with JS - ES6 and ReactJS in the past, but haven't had a chance to learn vue.js yet. I want to contribute to apache cloudstack, and this seems like a good first time issue to start with.
@davidjumani@utchoang Hi Guys! While working on this issue, I've come across instances of conditional operator which can be replaced by || operator to simplify the code, for e.g:
One more thing, where can I ask a question when I come across something in the code base which I am not sure about ? is there a slack channel, or forum of some kind ? Sorry, I am new to the cloudstack community.
Hello, I am Yashika Sarkar and I am new to open source but since ACS projects(2021) interests me I was going through the issues and I came across title "Optioinal chainging", I am not sure if it's an error but shouldn't it be optional chaining? #4956
Thank you.
@utchoang@davidjumani@rohityadavcloud Hello, I have come across certain lines of codes where optional chaining may be used .
Please let me know if it is okay to modify them or not ?
These are the screenshots- last line first and last line fourth line
Activity
simplycode by apache#4956
UI - zone wizard - fix undefined property when setting RBD primary st…
nvazquez commentedon Jul 13, 2021
Hi @davidjumani @utchoang - can you please confirm if PR #5167 which has been merged fixes this issue?
davidjumani commentedon Jul 14, 2021
@nvazquez This is a code wide change, the PR only fixes it in one place
nvazquez commentedon Jul 17, 2021
Thanks @davidjumani, please advise if/when there are more PRs about this issue. Perhaps we can also track them on the issue description using a task list
Damans227 commentedon Oct 18, 2021
@davidjumani quick question, how much of vue.js do I need to know in order to work on this issue ? I have worked with JS - ES6 and ReactJS in the past, but haven't had a chance to learn vue.js yet. I want to contribute to apache cloudstack, and this seems like a good first time issue to start with.
davidjumani commentedon Oct 23, 2021
@Damans227 it does not require a lot of Vue knowledge, just the basics of javascript to work on this
Damans227 commentedon Oct 27, 2021
@davidjumani @utchoang Hi Guys! While working on this issue, I've come across instances of conditional operator which can be replaced by || operator to simplify the code, for e.g:
this.items = response.listvlaniprangesresponse.vlaniprange ? response.listvlaniprangesresponse.vlaniprange : []Can be re-written to:
this.items = response.listvlaniprangesresponse.vlaniprange || []Would it be ok to make this change as part of this clean up effort ? Lemme know.
Thanks!
utchoang commentedon Oct 28, 2021
@Damans227 I think that's good. Let's do it.
Damans227 commentedon Oct 28, 2021
Alright, thx!
Damans227 commentedon Oct 28, 2021
One more thing, where can I ask a question when I come across something in the code base which I am not sure about ? is there a slack channel, or forum of some kind ? Sorry, I am new to the cloudstack community.
davidjumani commentedon Oct 29, 2021
@Damans227 You can shoot a mail on the dev mailing list dev@cloudstack.apache.org
Just be sure to be subscribed
Yashikaone commentedon Jan 25, 2022
Hello, I am Yashika Sarkar and I am new to open source but since ACS projects(2021) interests me I was going through the issues and I came across title "Optioinal chainging", I am not sure if it's an error but shouldn't it be optional chaining?
#4956
Thank you.
yadvr commentedon Jan 25, 2022
cc @borisstoyanov
Yashikaone commentedon Jan 28, 2022
@utchoang @davidjumani @rohityadavcloud Hello, I have come across certain lines of codes where optional chaining may be used .
last line
first and last line
fourth line
Please let me know if it is okay to modify them or not ?
These are the screenshots-
Thank you.
utchoang commentedon Feb 7, 2022
@Yashikaone These sections may be subject to optional code.
yadvr commentedon Aug 17, 2022
Looks like these have been fixed, if not pl re-reopen @davidjumani