Here is a different perspective on finding
the 'mode' of a sample from a continuous
distribution (where there are theoretically
no ties.)
Sometimes one tries to use a large sample from a continuous
population distribution to estimate the mode of the population.
Consider the following sample of size $n = 5000$ from
a population distributed $\mathsf{Beta}(3, 5),$
which has mode $2/6 = 0.3333$ according to this Wikipedia page. Of course, in a real application we would not know the population mode. [Using R.]
set.seed(225)
x = rbeta(5000, 3, 5)
summary(x)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.01159 0.25535 0.36605 0.37609 0.48496 0.91409
Using a histogram. Here is a histogram of the data:
hdr = "n=5000: From BETA(3,5)"
hist(x, prob=T, col="skyblue2", main = hdr)

The 'modal interval' of this histogram has the tallest
bar with base $(0.30, 0.35),$ so one might guess that
the mode of the population is between $0.30$ and $0.35.)$
Some elementary statistics books have formulas for
guessing the mode, supposedly more precisely, by
considering heights of nearby histogram bars.
Bear in mind that various histograms (with different bins) might result in somewhat different answers.
Using a density estimator. Independently of how any particular histogram of the data may be drawn, a kernel density estimator (KDE) attempts
to imitate the PDF of the population from the available data.
Below we show the KDE for our data (brown curve), and also the PDF
of the population distribution (dotted curve, which would ordinarily not be known in a real application).
lines(density(x), col="brown", lwd=2)
curve(dbeta(x, 3,5), add=T, lwd=2, lty="dotted")

The KDE in R is a sequence of 512 points $(x,y).$
So we can look for the highest point on the KDE plot, which corresponds to about $0.31$ on the horizontal axis.
xx = density(x)$x
yy = density(x)$y
mode = xx[yy==max(yy)]; mode
[1] 0.3080652
So, according to the KDE, the mode of the population
is estimated as about $0.31.$