Hello everyone, due to my poor foundation in js, I encountered many basic problems in the project, especially the concept of "everything is an object".
For example:
1,
$scope.dataArr={};
If I want to add attributes to it, $scope.dataArr.currTopic=xxxx is wrong;
However, $scope.dataArr[currTopic] is correct.
2. There is a key named currTopic in
$scope.dataArr, and the initial value is [ ].
I want to add value to the value of currTopic, that is, I want to push elements to [].
Using $scope.dataArr.currTopic.push(xxx) is wrong again.
$scope.dataArr[currTopic].push( xxx ) is correct.
why is that?
The attributes of click access and [] access are the same, and no error will be reported. The test results are as follows:
Please post error message