普通三元写法
name == 'tome' ? true :false
name == 'tome' ? 0 :(name == 'meimei' ? 1 :2)
多种可能
if(status == 0 || status == 1 || stauts == 2 || status == 3){
}
if([0,1,2,3].includes(status)){
}
let content = []
if(event == 'click'){
content = ['jump',clickFunction];
}else if(event == 'blur'){
content = ['jungle',blurFunction]
}else if(event == 'scroll'){
content = ['scroll',scrollFunction]
}else {
content = ['other',otherFunction]
}
let content = []
const eventObject = {
'click':['jump',clickFunction],
'blur':['jungle',blurFunction],
'scroll':['scroll',scrollFunction],
}
content = eventObject[event] || ['other',otherFunction]
if(status === 0) {
text = '已删除'
} else if (status === 1) {
text = '未开始'
} else if (status === 2) {
text = '上课中'
} else if (status === 3) {
text = '已下课'
} else if (status === 4) {
text = '已评估'
} else {
text = '--'
}
switch(status) {
case 0:
text = '已删除';
break;
case 1:
text = '未开始';
break;
case 2:
text = '上课中';
break;
case 3:
text = '已下课';
break;
case 4:
text = '已评估';
break;
default:
text = '--';
break;
}
const statusTextArray = ['已删除', '未开始', '上课中', '已下课', '已评估'];
text = statusTextArray[status] || '--';
const statusTextObject = {
100: '已删除',
101: '未开始',
102: '上课中',
103: '已下课',
104: '已评估'
}
text = statusTextObject[status] || '--';
if (limit === 'super') {
if(status === 0) {
else if (status === 1) {
else if (status === 2) {
else if (status === 3) {
else if (status === 4) {
} else if (limit === 'normal') {
if(status === 0) {
else if (status === 1) {
else if (status === 2) {
else if (status === 3) {
else if (status === 4) {
} else {
}
const limitStatusObject = {
'super-0': () => {
'super-1': () => {
'normal-0': () => {
'normal-1': () => {
}
const limitStatusObject = {
'super-0': super0Function,
'super-1': super1Function,
'normal-0': normal0Function,
'normal-1': normal1Function,
}
limitStatusObject[`${limit}-${status}`].call(this);
const limitStatusMap = new Map([
[{limit: 'super',status: 0},()=>{
[{limit: 'super',status: 1},()=>{
[{limit: 'normal',status: 0},()=>{
[{limit: 'normal',status: 1},()=>{
]);
const list = [...limitStatusMap].filter(([key,value]) => (key.limit === limit && key.status === status));
list.forEach(([key,value]) => value.call(this));