+ 1
Array name
Can we change the name of an array from arr to anything else?
3 ответов
+ 4
It's how you create it.
Variables can have any name.
+ 4
like if there's already an array named arr,
you wanna create an array called rando,
just set the value of rando to arr.
0
You can name them however you need to. If I had an array of all the classes I'm taking I could name it currentClasses, or myClasses, or whatever else I wanted.
Now say I had another array with the list of my teachers I could call it myTeachers, or currentTeachers. Whatever helps you recognize what the array is for.
If I named my array of teachers Hrjfoebt, that would technically work, but it wouldn't be easy to remember, or type a lot of times.
The general naming convention for arrays is to name it something meaningful, that way if someone else looks at your code they can tell what's in the array just by reading the name. It's also standard to make the first word lowercase, and any other words title case. likeThisExample This is called Camel-case, and just helps to make it easier to read at a glance. readingthissentence is harder than readingThisSentence.