CoreUI ONE — 250+ PRO components and 25+ admin templates for React, Angular, Vue, Bootstrap and Next.js, plus Data Grid, Scheduler, 4,300+ PRO icons and the Next.js boilerplate. One license. → See what you get

How to capitalize the first letter of a string in JavaScript

Capitalizing the first letter of strings is essential for proper name formatting, title case conversion, sentence formatting, and creating polished user interfaces in JavaScript applications. As the creator of CoreUI, I’ve implemented first letter capitalization in components like form inputs, user profiles, and content displays where proper text formatting enhances professionalism and readability. From my extensive expertise, the most reliable and widely supported solution is combining charAt(0).toUpperCase() to capitalize the first character with slice(1) to preserve the rest of the string. This approach handles edge cases gracefully and works consistently across all JavaScript environments.

Read More…

How to publish a React component to npm

Publishing a React component to npm is the gold standard for sharing reusable UI logic across projects or with the developer community. As the creator of CoreUI, I’ve built and published hundreds of packages that power thousands of applications worldwide. The most efficient and modern approach involves bundling your component using a tool like Rollup to support both ESM and CommonJS formats while managing dependencies correctly. This ensures your library is lightweight, tree-shakeable, and compatible with various build environments like Vite, Next.js, or Webpack.

Read More…

How to shuffle an array in JavaScript

Shuffling arrays is crucial for randomizing data presentation, creating quiz questions, implementing card games, and providing varied user experiences in JavaScript applications. As the creator of CoreUI, I have implemented array shuffling in components like image galleries, testimonial carousels, and dashboard widgets where randomized content keeps interfaces fresh and engaging. From my extensive expertise, the most mathematically sound and efficient solution is implementing the Fisher-Yates shuffle algorithm, which ensures truly uniform random distribution. This approach is unbiased, performant, and provides the gold standard for array randomization in computer science.

Read More…

How to get the last element of an array in JavaScript

Accessing the last element of arrays is essential for retrieving the most recent item, implementing stack operations, and getting final values in data processing within JavaScript applications. As the creator of CoreUI, I have accessed last elements extensively in components like activity feeds, pagination controls, and timeline displays where the final item often represents the current state or latest entry. From my extensive expertise, the most reliable and universally supported approach is using array index notation with array.length - 1 to access the final position. This method is dependable, works across all JavaScript versions, and clearly expresses the intent to access the last element.

Read More…

How to get the first element of an array in JavaScript

Accessing the first element of arrays is fundamental for processing data sequences, implementing queue operations, and retrieving initial values in JavaScript applications. As the creator of CoreUI, I have accessed first elements countless times in components like breadcrumb navigation, carousel displays, and data lists where the initial item often has special significance or styling. From my extensive expertise, the most straightforward and universally supported approach is using array index notation with [0] to access the first position. This method is direct, readable, and works consistently across all JavaScript environments without any dependencies.

Read More…

How to find the minimum value in an array in JavaScript

Finding the minimum value in numeric arrays is crucial for data validation, setting lower bounds, calculating ranges, and implementing features like price filters or threshold alerts in JavaScript applications. As the creator of CoreUI, I have implemented minimum value calculations in components like slider controls, budget trackers, and validation systems where identifying the lowest values ensures proper data boundaries. From my extensive expertise, the most elegant and efficient solution is using Math.min() combined with the spread operator to find the smallest number. This approach is concise, performant, and utilizes JavaScript’s built-in mathematical functions for reliable results.

Read More…

How to find the maximum value in an array in JavaScript

Finding the maximum value in numeric arrays is essential for data analysis, creating charts, determining price ranges, and implementing features like progress bars or statistical displays in JavaScript applications. As the creator of CoreUI, I have implemented maximum value calculations in components like dashboard charts, pricing tables, and analytics widgets where identifying peak values is crucial for data visualization. From my extensive expertise, the most elegant and efficient solution is using Math.max() combined with the spread operator to find the largest number. This approach is concise, readable, and leverages JavaScript’s built-in mathematical functions for optimal performance.

Read More…

How to sort an array in JavaScript

Sorting arrays is essential for organizing data, creating alphabetical lists, arranging numbers in order, and providing users with structured, easily scannable information in JavaScript applications. As the creator of CoreUI, I’ve implemented array sorting in countless components like data tables, dropdown menus, and leaderboards where proper data ordering enhances user experience. From my extensive expertise, the most modern and safe solution is the ES2023 toSorted() method, which returns a new sorted array without mutating the original. For in-place sorting, the classic sort() method remains the fastest option.

Read More…

How to reverse an array in JavaScript

Reversing the order of array elements is useful for displaying data in descending order, implementing undo functionality, or creating reverse chronological lists in JavaScript applications. As the creator of CoreUI, I’ve implemented array reversal in components like activity feeds, breadcrumb navigation, and timeline displays where the most recent items need to appear first. From my extensive expertise, the most modern and safe solution is using the ES2023 toReversed() method, which returns a new array without mutating the original. For in-place reversal, the classic reverse() method remains the fastest option.

Read More…

How to remove duplicates from an array in JavaScript

Dealing with duplicate values in JavaScript arrays is a common issue, especially when working with data from APIs or user input where duplicate entries can occur unexpectedly. As the creator of CoreUI, I’ve solved this problem countless times in production components like user lists, tag systems, and data aggregation features where clean, unique datasets are essential. From my extensive expertise, the most efficient and modern solution is to use the ES6 Set object together with the spread operator. This method is concise, reliable, and supported across all modern browsers while maintaining excellent performance.

Read More…
Subscribe to our newsletter
Get early information about new products, product updates and blog posts.