top of page
  • Writer's pictureEvgeniy M.

I Wrote These 10+ Single Lines of JavaScript Code; the Team Lead Praised the Code for Being Elegant



The very big features of JavaScript are easy to use and very flexible, and there are various ways of code implementation; sometimes it can be solved with one line of code, so try not to use two lines.


This article has compiled a very useful one-line code. These requirements are very common in development. Using a single line of code can help you improve your work efficiency.


Get parameters from url and convert them to object


The web page path is often in the form of: www.google.com.hk?search=js&xxx=kkk. We often need to take parameters, which can be implemented by using a third-party qs package. If you just want to remove parameters, this sentence of code will It can be achieved without introducing qs.


Check whether the object is empty


Checking if the object is empty is actually not that simple. Even if the object is empty, it returns false every time it checks if the object is equal to {}.

Comments


bottom of page