starMap={
B: 'COM',
C: 'B',
D: 'C',
E: 'D',
F: 'E',
G: 'B',
H: 'G',
I: 'D',
J: 'E',
K: 'J',
L: 'K',
YOU: 'K',
SAN: 'I'
};
const getAncestors = body => body in starMap ? [ ...getAncestors(starMap[body]), starMap[body] ] : [];
console.log(getAncestors("YOU"));
const getAncestors=body=>尸体在星际地图上?[…getAncestors(starMap[body](,starMap[body]]:[]
我会理解除了getanother(starmap[body](之外的其他所有东西
starMap
是对象getAncestors
是一个函数,如果参数body
在对象starMap
中,则返回true?操作员的意思类似于
let tog = 1 == 1 ? 'Yeah it is' : 'Nope'
这与相同
if(1==1){
let tog = 'Yeah it is'
}
else {
let tog = 'Nope'
}
CCD_ 6与
const getAncestors = (body) => {
return body in starMap; //true or false
}