Got tired of learning and want to get some cool tricks up your sleeve to earn the right to show off? You have come to the right place. Here are nea...
For further actions, you may consider blocking this person and/or reporting abuse
Think about 0 and "" with && and ||, the are also falsy and sometimes you do not want that. Thats the reason for ?? I would think.
Also sometimes nice but dangerous: monkey patching.
Gives also no error for value types like string and number, but looses the value.
Better forget it, its bad style. ;-)
Yeah I agree, it's NOT a recommended approach of resizing arrays. Added that just to showcase that it's also a setter which most people don't know
I think it is a best way to make the array empty. This can be used
array.length = 0
in place ofarray = []
because prior one is faster than the later one.We should not use the fastes method but the method who is understood.
Thats not monkey patching.
Wth?
length
is also a setter?My whole life is a lie...
Man...
You never know. 😂Life is a lie in general. But we move..
For "Replace all" you can also just use the
replaceAll
method - which could be considered more readable._Readable numbers _ is something which I never knew about, thanks a lot for that !!!
One more :
Swapping 2 array elements.
Hi Tapajyoti Bose,
thank you for your article.
I already knew two of the 7 tricks when reading your article.
The other five are pretty neat in my opinion :D!
first one is called grouping integers
The array length setter was really surprising.
Hi! Very useful tips.
Thank you very much for sharing. 🙏
Already used some of your advises...
It's great