I don't understand this because java is my first programming language.
In java, variables inside of parentheses should be declared
For example
public int checkUserName(int minLength){
//some codes
}
but in javascript
function checkUsername(var minLength){
//some codes
}
shows an unexpected token var error
I know Java and JavaScript are two different languages but I just want to know why isn't it allowed in JavaScript. I know it is not allowed I just want to know why.
I asked this because my JavaScript book does not explain me why JavaScript does not allow that. It just says you should write so but not WHY.