How do we define variables specific to the scope of JavaScript class?
In this fiddle below, I would like to define a variable called name specific to the class Person. I am getting an error SyntaxError: missing : after property id
var Person = {
var name = "Jake";
printName: function()
{
document.getElementById("personName").val(this.name);
}
};
Person.printName();
Personis an object, not a class. Objects can only have properties. They don't have a concept of "local variables".