亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - The problem of everything in js being an object
為情所困
為情所困 2017-06-16 09:19:22
0
2
945

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?

為情所困
為情所困

reply all(2)
曾經(jīng)蠟筆沒有小新

The attributes of click access and [] access are the same, and no error will be reported. The test results are as follows:

學(xué)霸

Please post error message

var $scope={};
$scope.dataArr={};
$scope.dataArr.currTopic="XXXXX";
$scope.dataArr["currTopic"]="YYYYYY";

$scope.dataArr.currTopic=[];
$scope.dataArr.currTopic.push("AAAAAAA");
$scope.dataArr["currTopic"].push("BBBBBB");
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template