In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "what JS streamlined code". In daily operation, I believe many people have doubts about which JS streamlined code. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what JS streamlined code?" Next, please follow the editor to study!
calendar
Create an array for the past seven days, and if you replace the minus sign with a plus sign in the code, you will get a collection of arrays for the next seven days.
/ / create an array of the past seven days [. Array (7). Keys ()] .map (days = > new Date (Date.now ()-86400000 * days))
Generate random ID
The function of creating ID is often used in prototype design, but I see people using it in actual projects, which is actually quite unsafe.
/ / generate a random alphanumeric string of length 11 Math.random () .toString (36) .substring (2); / / hg7znok52x
Get the query parameters of URL
Gets the query parameters in URL.
/ / get the query parameters of URL: Q = {}; location.search.replace (/ ([^? & =] +) = ([^ &] +) / g, (_, kheroin v) = > Q [k] = v); Q
Get local time
Through a pile of js code, you can get the local time
/ / create local time document.body [XSS _ clean] = new Date (). ToLocaleString (). Slice (10jue 19) ">
Array confusion
Used to randomly change the order of elements in an array
/ / randomly change the order of the elements of the array, confusing the array (arr) = > arr.slice (). Sort () = > Math.random ()-0.5) / * let a = (arr) = > arr.slice (). Sort () = > Math.random ()-0.5) let b = a ([1m (b)]) console.log (b) * /
Generate random colors
Used to generate random colors
/ / generate random hexadecimal codes such as:'# c618b2''#'+ Math.floor (Math.random () * 0xffffff) .toString (16) .padEnd (6,'0')
Do you know the result of this code running?
For [. "``1234567890-=~~QWERTYUIOP []\ ~ ASDFGHJKL;'~~ZXCVBNM,./~"] .map (x = > (ofex = `/ ${b='_'.repeat (wrapx))
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.