I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
because it reads like assigning 'foo' to foo and then assigning bar.foo to foo to override it... but it's a const. I mean, I've tried it and it behaves like your const age = unicorn.age !== undefined ? unicorn.age : 5 example, but that's not what it looks like it should do. What's in the box, amirite?
I like this.
I'm not so sure how I feel about
because it reads like assigning 'foo' to
foo
and then assigningbar.foo
tofoo
to override it... but it's aconst
. I mean, I've tried it and it behaves like yourconst age = unicorn.age !== undefined ? unicorn.age : 5
example, but that's not what it looks like it should do. What's in the box, amirite?I agree that the syntax for that is really confusing. Every time I write it, I have to check to make sure I'm putting things in the right place.
It gets even more confusing when you also rename properties:
What it does is essentially: