简体   繁体   English

具有相同值的多个Javascript变量

[英]Multiple Javascript variables with the same value

$scope.visibilityEnabled = 'Disabled';
$scope.invertEnabled = 'Disabled';
$scope.weightEnabled = 'Disabled';
$scope.saturationEnabled = 'Disabled'

I have the above Javascript variables, would it be possible to simplify them down at all and make them efficient? 我有上面的Javascript变量,是否有可能将它们简化下来并提高效率?

This should work also in Javascript 这也应该在Javascript中工作

 $scope.visibilityEnabled = 
 $scope.invertEnabled = 
 $scope.weightEnabled = 
 $scope.saturationEnabled = 'Disabled';

You could fairly simply change the values of all of the variables within your script to be the same name, but it wouldn't really make it any more efficient. 您可以相当简单地将脚本中所有变量的值更改为相同的名称,但实际上并不能使其效率更高。 It appears that the variables are configuration values, so there is really no reason to do anything with them except change the values to modify the behaviour of the script. 看来变量是配置值,因此,除了更改值以修改脚本的行为外,实际上没有任何必要使用它们。

If you're determined that there will be only one variable, use a find and replace editor, but it won't make it more efficient. 如果确定只有一个变量,请使用查找和替换编辑器,但这不会使其更有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM