代码如下,为什么下面两个格式都不会报错,都是什么意思。这么使用会不会有什么问题
The code is as follows. What do they mean? Will there be any problem with this use?
//问题一
//这种方式在获取的时候可以直接访问,为什么?
//question 1
//This method can be accessed directly when it is acquired. Why?
let varis = {
int:a1=2,
int:b1=3,
float:c1 = 4.6,
string:d1="i am string d1",
dasdsad:e1="i am string el"
};
console.log(a1);//2
console.log(b1);//3
console.log(c1);//4.6
console.log(d1);//i am string d1
console.log(e1);//i am string e1
//问题二
//这种方式获取对象里的值还是普通的对象方式
//question 2
//This way gets the value in the object use the normal object mode
//
let varis = {
a1:int=2,
b1:int=3,
c1:float = 4.6,
d1:string="i am string d1",
e1:eqwedsad="i am string el"
};
console.log(a1);//2
console.log(b1);//3
console.log(c1);//4.6
console.log(d1);//i am string d1
console.log(e1);//i am string e1
以上代码其实就是先对a1等赋值,然后将其赋值表达式的返回值再传递给int等varis的key。
这样错是不会有错。。就是可能会让读你代码的人一脸懵逼-。-