[英]Python dictionaries in javascript
I didn't really know how to parse the title very well but, what I need help with is I was watching a tutorial on how to make a programming language in python.我真的不知道如何很好地解析标题,但是,我需要帮助的是我正在观看有关如何在 python 中制作编程语言的教程。 I wanted to make it in javascript.我想用javascript制作它。 I got the lexer working but then came to the parser.我让词法分析器工作,但后来来到解析器。 In the tutorial they do this:在教程中,他们这样做:
t = {token['value']: []}
I want to do that in javascript.我想在 javascript 中做到这一点。 But when I try to do that I can user the token['value'] part to as a 'label' so to say.但是当我尝试这样做时,我可以将 token['value'] 部分用作“标签”。
Thanks!谢谢!
You may be looking for computed properties:您可能正在寻找计算属性:
const t = {
[token.value]: []
};
Then you will be able to access t[token.value]
.然后您将能够访问t[token.value]
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.