admin管理员组文章数量:1394163
I am getting syntax error while pressing js file using a mand line tool yuipressor jar.
[ERROR] 1796:28:invalid property id
I have a variable mentGroup
. I want to push it as JSON object with the value of mentGroup as key
. To achieve this I referred this answer.
var mentGroup = 'owner';
var groupIndex= [];
groupIndex.push({[mentGroup]: 1}); // Error line 1796
Why is it telling invalid property id?
I am using yuipressor-2.4.7.jar
I have tried above code on JavaScript/CSS/HTML Compressor
Output
{
"message": "Unexpected token: name (mentGroup)",
"filename": 0,
"line": 3,
"col": 18,
"pos": 66
}
I think YUI pressor does not understand {[mentGroup]: 1}
I got the solution for above problem, I need to declare temporary variable, then I put my object as a key into that variable and then pushed into the array.
var mentGroup = 'owner';
var aObject= {};
aObject[mentGroup]= 1;
var groupIndex= [];
groupIndex.push(aObject);
I am getting syntax error while pressing js file using a mand line tool yuipressor jar.
[ERROR] 1796:28:invalid property id
I have a variable mentGroup
. I want to push it as JSON object with the value of mentGroup as key
. To achieve this I referred this answer.
var mentGroup = 'owner';
var groupIndex= [];
groupIndex.push({[mentGroup]: 1}); // Error line 1796
Why is it telling invalid property id?
I am using yuipressor-2.4.7.jar
I have tried above code on JavaScript/CSS/HTML Compressor
Output
{
"message": "Unexpected token: name (mentGroup)",
"filename": 0,
"line": 3,
"col": 18,
"pos": 66
}
I think YUI pressor does not understand {[mentGroup]: 1}
I got the solution for above problem, I need to declare temporary variable, then I put my object as a key into that variable and then pushed into the array.
var mentGroup = 'owner';
var aObject= {};
aObject[mentGroup]= 1;
var groupIndex= [];
groupIndex.push(aObject);
Share
Improve this question
asked Nov 9, 2017 at 6:29
Kaustubh KhareKaustubh Khare
3,5103 gold badges38 silver badges50 bronze badges
1 Answer
Reset to default 4That's because what you have used is ES6 syntax. And YUI Compressor is not supporting ES6 yet.There's open ticket here.
本文标签: yui compressor giving syntax error for valid javascript syntaxStack Overflow
版权声明:本文标题:yui compressor giving syntax error for valid javascript syntax - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744749804a2623105.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论