I've been a little busy building cenario over the past few months and shining my coding skills again.
During this period I remembered/learnt a lot...
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
for validations, do explore object proxies.
developer.mozilla.org/en-US/docs/W...
Proxies are not talked about enough!
Thanks for this!
Nice tricks!
But why did you put screenshots of code instead of blocks of code?
See markdown cheatsheet here.
I'll get back to this article in a few days and I'm sure I'll see at least one comment from an "experienced" developer about how this code is not readable and how junior developers should not try this.
That "experienced" developer is usually someone who has been working in the same company for the last 3 years, which is also probably the only company where he worked at.
That person is probably also very vocal about how amazing Java is and how horrible PHP is.
Hey mate!
Thanks for the comment, honestly I was just exploring different styles of writing this blog. If you have a chance of checking out the previous blogs I've used the markdown approach 😀
That's fair but I tried being very particular about those tricks, and ensuring these are just good practices as well as be "tricks" at the same time.
So lets hope someone like that isn't too unimpressed with this 😉
Thanks again, hope you have a fantastic day!
This decade-old engineer approves.
In addition to 'Reallocating variables', object-like destructuring of arrays is a trick I don't see that often.
Or to make it even more ridiculous, you may want to destructure just the age of the secondPerson, but also keep the secondPerson object as a whole.
Jesus Christ, at this point I would probably have just done it in a non destructured way haha.
Pretty neat though
The correct name for your null checker is optional chaining. And beware, its not supported on mobile browsers and IE.
developer.mozilla.org/en-US/docs/W...
Using the Babel preset will be sufficient enough
not everyone uses babel
Fair play - will update the article to reflect :)
You can remove items from an array by using the filter function by giving the desire value comparing the difference
Yeah but this is a O(n) complexity, array.length = whatever is O(1) :)
Unless we're talking about two different things ofc 😂
I always have to look up slice vs splice, lol xdd
The one I almost always forget I'd the argument structure of reduce 🤣
May I ask what's the difference between
{ date: objDate } = obj
vs.objDate = obj.date
?Literally nothing, its just a pattern some people use. I try not to always do destructed reassignment because it looks "messy" but sometimes I inherit projects where destructuring is used across the project and to stay consistent i keep with this pattern
There is one important difference: destruction shallowly clones the object. This is very important when considering referential transparency.
Would love for you to expand on this further. I agree with you and have a similar understanding however keen to know your views
This was amazing! Thanks for sharing!
No worries!
Arrays do have slice.
You're right lol, how did I miss that. Since arrays act like string stacks anyway. Fixed it :)
This was a good read. Thanks for sharing Vaibhav!
Thanks Dinesh! Glad you liked it!
Thanks for sharing Vaibhav. yes., above are simple tricks that we will be using every day in our code.
Thanks Ramesh! Really appreciate it!