JS 依照元素出現數量排序
同樣是最近遇到的狀況,需要利用陣列內元素出現的數量進行排序,以下為範例程式:
var array = ["1", "2", "4", "5", "2", "4", "2", "3"]; var str = array.toString(); var filter = []; var result = []; document.write("原始陣列:" + array + "<br>"); var get = function (str, tar, arr, tmp) { if (str.indexOf(tar) >= 0) { tmp = str.slice(str.indexOf(tar) + 1); arr.push(tar); get(tmp, tar, arr, tmp); } return arr; } for (i in array) { var elm = []; var tmp; var fstr = filter.join(); if (fstr.indexOf(array[i]) >= 0) { continue; } else { var tmp_arr = get(str, array[i], elm, tmp); result.push(tmp_arr.length + ':' + tmp_arr[0]); filter.push(array[i]); } } result.sort(); result.reverse(); //按照出現次數排序,不刪除重複元素 var finishArray = []; for (index in result) { var show = result[index].split(':'); for (i = 0; i < show[0]; i++) { finishArray.push(show[1]); } } document.write("按出現次數排序,不刪除重複元素:" + finishArray + "<br>"); //按照出現次數排序,刪除重複元素 var finishArray = []; for (index in result) { var show = result[index].split(':'); finishArray.push(show[1]); } document.write("按出現次數排序,刪除重複元素:" + finishArray + "<br>");
輸出結果:
原始陣列:1,2,4,5,2,4,2,3 按出現次數排序,不刪除重複元素:2,2,2,4,4,5,3,1 按出現次數排序,刪除重複元素:2,4,5,3,1
pharmacie en ligne france fiable: Acheter Cialis – acheter mГ©dicament en ligne sans ordonnance
A Look At The Myths And Facts Behind Anxiety Disorder Physical Symptoms What Are Anxiety Attack Symptoms
Article writing is also a excitement, if you be acquainted with afterward you can write otherwise it
is difficult to write.
Wow a good deal of awesome facts.
What’s up colleagues, pleasant post and
fastidious arguments commented at this place, I am in fact
enjoying by these.
You actually suggested it perfectly.
Appreciate it! Numerous postings.
Горные велосипеды купить velosiped-magazin.ru
Если Вы планировали найти велосипед заказать в Москве, то звоните прямо сейчас. Номер телефона +7(495)128-48-26 для связи и предоставлению консультации. Наши менеджеры помогут с выбором и оформят Вам заказ с доставкой по Москве.
SildГ©nafil 100mg pharmacie en ligne Viagra sans ordonnance 24h Viagra sans ordonnance livraison 24h
Viagra gГ©nГ©rique sans ordonnance en pharmacie viagra sans ordonnance Viagra pas cher paris
http://pharmaciepascher.pro/# pharmacie en ligne pas cher
Cheers! I appreciate it!
Acheter Sildenafil 100mg sans ordonnance: Viagra sans ordonnance 24h – Viagra vente libre pays
Nicely put, Kudos.
mexico drug stores pharmacies: medication from mexico – buying from online mexican pharmacy
medication from mexico pharmacy
Пошаговая инструкция по безопасной покупке диплома о высшем образовании
Quand une femme prend du Viagra homme: viagra sans ordonnance – Viagra sans ordonnance 24h Amazon
Viagra Pfizer sans ordonnance: Sildenafil Viagra – Prix du Viagra 100mg en France
10 Things You Learned In Kindergarden Which Will Aid You In Obtaining How To Get Diagnosed With ADHD getting Diagnosed With adhd as an adult
Look into my page; Find top-rated certified Daycares in your area
https://clssansordonnance.icu/# vente de mГ©dicament en ligne
Having read this I thought it was rather enlightening.
I appreciate you finding the time and energy to put this short article together.
I once again find myself spending a lot of time both reading and
posting comments. But so what, it was still worth it!
I do trust all of the ideas you have offered to your post.
They’re really convincing and will certainly work. Nonetheless, the posts are very brief for novices.
May you please lengthen them a bit from next
time? Thank you for the post.
Pharmacie Internationale en ligne: cialis sans ordonnance – п»їpharmacie en ligne france
I am sure this article has touched all the internet users, its really really fastidious piece of writing on building up new website.
Feel free to surf to my blog servizi di traduzione giuridica
acheter mГ©dicament en ligne sans ordonnance cialis prix pharmacie en ligne livraison europe
I have read so many articles or reviews concerning the blogger lovers but
this post is truly a fastidious piece of writing,
keep it up.
SildГ©nafil 100 mg prix en pharmacie en France Sildenafil Viagra SildГ©nafil 100 mg prix en pharmacie en France
Prologue
In a society that evolves at rapid speed, the ability to innovate isn’t just advantageous—it’s crucial. Whether you’re an business owner, a business leader, or a coder, staying in the lead requires an innovative mindset. This blog post will explore the notion of innovation, uncovering what it takes to be a real innovator and why it’s more important now than ever. You’ll learn characteristics that characterize successful innovators, discover encouraging case studies, and gain practical strategies for fostering your own original thinking.
What is Innovation and Why Does it Matter?
Innovation is more than just a catchphrase; it’s the core of progress. It requires creating new ideas or improving existing ones, leading to concrete benefits. In today’s fast-paced environment, businesses must innovate to exist and flourish. Innovation propels effectiveness, enhances customer interaction, and opens new income streams. Without it, stagnation is unavoidable.
Traits of a True Innovator
Creativity
https://ko-fi.com/rileyreesepurdue
At the core of innovation is creativity. This characteristic allows individuals to think beyond the box, generating original solutions to complicated problems. Imaginative thinking can be nurtured by presenting oneself to diverse perspectives and backgrounds.
Adaptability
In a quickly changing world, an innovator must be flexible. Being able to pivot when faced with new hurdles or opportunities is essential. Adaptability assures that you can evolve alongside market changes and technological advancements.
Risk-Taking
Innovation often requires venturing into the unexplored. True innovators are willing to take measured risks. They understand that failure is a part of the path and use it as a learning tool to improve their ideas.
Case Studies of Successful Innovators
Elon Musk
Elon Musk’s groundbreaking ventures, from Tesla to SpaceX, have transformed industries. His preparedness to tackle enormous technological challenges and shake up established markets showcases the strength of a bold vision.
Sara Blakely
Sara Blakely, the entrepreneur of Spanx, turned a straightforward idea into a billion-dollar conglomerate. Her innovation in the clothing industry demonstrates how solving everyday problems can lead to extraordinary success.
Steve Jobs
Steve Jobs’ persistent pursuit of innovation transformed Apple into a global tech giant. His focus on design and user interaction set new standards for the industry, proving that innovation can be a key advantage.
Fostering an Innovative Mindset
Encourage a Culture of Openness
Creating an atmosphere where new ideas are embraced and valued is crucial. Organizations should support employees to share their ideas without fear of judgment. This openness fosters cooperation and sparks creativity.
Learn from Failure
Failure is an certain part of the innovation path. Instead of fearing it, innovators should view failure as an opportunity to learn and grow. Examining what went wrong and why can provide valuable insights for future endeavors.
Embrace New Technologies
Digital advancements offer endless opportunities for innovation. Staying current with the latest trends and tools can provide a competitive edge. Whether it’s AI, blockchain, or IoT, leveraging new technologies can lead to significant breakthroughs.
The Role of Innovation in Business Growth
Driving Efficiency
Innovative processes can streamline operations, reducing costs and enhancing efficiency. Automation and digital transformation are illustrations of how businesses can innovate to enhance productivity.
Enhancing Customer Experience
Innovation can significantly improve customer satisfaction. By understanding customer demands and developing customized solutions, businesses can foster loyalty and encourage growth. Tailored services and innovative products can set a company apart from its peers.
Opening New Revenue Streams
Innovative thinking can uncover new commercial opportunities. Diversifying product lines, entering new markets, or developing unique services can open new revenue streams. This diversification mitigates risk and promotes sustainable growth.
Conclusion
Innovation is the driving force behind progress in today’s ever-changing world. By understanding the traits of true innovators, learning from successful case studies, and fostering an innovative mindset, you can unlock your creative potential. Remember, innovation isn’t just about revolutionary inventions; it’s about making continuous improvements that add value. Whether you’re leading a team or pursuing solo projects, the ability to innovate will set you apart and drive your success. Now, it’s time to put these insights into action and start your own original journey.
Профессиональный сервисный центр по ремонту объетивов в Москве.
Мы предлагаем: ремонт объектив фотоаппарат
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!