In most cases it is enough with an implicit declaration in bash
asdf="some text"
But, sometimes you want a variable's value to only be integer (so in case it would later change, even automatically, it could only be changed to an integer, defaults to zero in some cases), and can use:
declare -i num
or
declare -i num=15
Sometimes you want arrays, and then you need declare
declare -a asdf # indexed type
or
declare -A asdf # associative type
You can find good tutorials about arrays in bash
when you browse the internet with the search string 'bash array tutorial' (without quotes), for example
linuxconfig.org/how-to-use-arrays-in-bash-script
I think these are the most common cases when you declare variables.
Please notice also, that
in a function,
declare
makes the variable local (in the function)without any name, it lists all variables (in the active shell)
declare
Finally, you get a brief summary of the features of the shell built-in command declare
in bash
with the command
help declare