After some research, I guess I found the most suitable solution for me, that's why I mark this answer as 'accepted'. However, please consider other answers as well, because they might be more appropriate for your needs.
Here are two similar approaches:
\documentclass{article}
\usepackage{tikz}
\begin{tikzpicture}
\def\points{{{0.31,-0.23}, {1,0.68}, {0.54,1.35}, {2,2}}}
\pgfmathsetmacro{\len}{dim(\points)-2}
\foreach \i [evaluate={\ax=\points[\i][0]; \ay=\points[\i][1]; \bx=\points[\i+1][0]; \by=\points[\i+1][1]}]
in {0,...,\len}{
\draw (\ax,\ay) -- (\bx,\by);
}
\end{tikzpicture}
\end{document}
\documentclass{article}
\usepackage{tikz}
\begin{tikzpicture}
\def\points{{{0.31,-0.23}, {1,0.68}, {0.54,1.35}, {2,2}}}
\pgfmathsetmacro{\len}{dim(\points)-2}
\foreach \i in {0,...,\len}{
\pgfmathsetmacro{\ax}{\points[\i][0]}
\pgfmathsetmacro{\ay}{\points[\i][1]}
\pgfmathsetmacro{\bx}{\points[\i+1][0]}
\pgfmathsetmacro{\by}{\points[\i+1][1]}
\draw (\ax,\ay) -- (\bx,\by);
}
\end{tikzpicture}
\end{document}
I think it worth referencing these posts that came in useful while looking for the solution:
Iteratively draw and connect nodes via `\foreach`
Draw a path between many nodes using foreach
Given an array of 2D points, how to access individual elements in TikZ?
2D tikz matrices: iteration and addressing elements
array of coordinates and array of strings
TikZ \foreach loop evaluate variable using pgfmath function
\foreach has a problem with ‘initially’ argument in remember part
pgfmathparse in foreach, use result as node coordinates
tikz foreach index in variable name
And also an example in subsection 94.2 Syntax for Mathematical Expressions: Operators at p. 1033

\draw (0.31,-0.23)--(1,0.68)--(0.54,1.35)--(2,2);? – egreg Nov 06 '21 at 13:29\points. – antshar Nov 06 '21 at 13:34