This article analyzes two ways of accessing object properties in JavaScript. Share it for your reference. The details are as follows:
There are two ways for javascript to access object properties. The following code looks like:
Copy the code as follows:<script language="javascript" type="text/javascript">
function Person(){};
var p1 = new Person();
p1.name="沪歌";
document.writeln(p1.name+"<br />");
document.writeln(p1['name']);
</script>
I hope this article will be helpful to everyone's JavaScript programming.