Don't forget let and const are already block scoped, so a simple alternative to your let block example is this:
letcatName='Oswald'letcatAge=2.5{letcatName='Luna',catAge=2console.log(`${catName} (${catAge} years old)`)// Luna (2 years old)}console.log(`${catName} (${catAge} years old)`)// Oswald (2.5 years old)
I've to say JavaScript changed so much that its hard to keep track of what have changes... But Proxy thing is just blew my mind. I never knew it was available. Thanks a lot
let Bio = {
username: 'hyggedev',
fullName: 'Chris Hansen',
bio: 'I create⚡️ fast modern, client-side websites with React and Javascript.',
passion: ['Blog', 'Tweet', 'Code']
};
Some example with
withTo watch Object change, you can also
Object.definePropertyGreat list, I didn't have a clue about some of those :)
One other way of doing a "with like thing" having a go at the C# syntax I've seen is this:
That's nice!
Yup, that's another way of doing it - although that will return
in the browser since
locationis a global property - we can rename it to something else though.Don't forget
letandconstare already block scoped, so a simple alternative to yourletblock example is this:You're right, thanks - I'll update the article now.
I've to say JavaScript changed so much that its hard to keep track of what have changes... But
Proxything is just blew my mind. I never knew it was available. Thanks a lotI only knew about with, which is used sometimes on code golfing 🙂 Nice article!
HTML wrapper methods on strings: "There are no alternatives for this monstrosity." Hahah 🤣 Wow, never knew they even exist tbh. Great stuff, thanks!
Thanks! This was very informative.
great post thanks .
Glad you liked it!
Nice post! Some of those are obscure, did not now a couple of them
👍🏽
Awesome article!
Great post! I thought 'with' was a fever dream from my teenage years.
You're welcome!