JSFiddle - React, Tailwind, and code Playground
by ilyabezp
JavaScript
a = [1,2,3,4,5];
b = 522;
c = false;
for (var i = 0; i < a.length; i++) {
if(a[i]===b){
a.splice(i,1);
a.unshift(b);
c = true;
}
}
if(!c){
a.pop();
a.unshift(b);
}
alert(a);
alert(a.length);
var abcabc = JSON.parse(localStorage.getItem('m')),message_count = abcabc.count;
if(message_count>0){
cVar = false;
for(var iphone = 0; iphone < message_count; iphone++){
var tempVar = abcabc.items[iphone];
messId = typeof(tempVar.chat_id)==='number'?tempVar.chat_id+2000000000:tempVar.user_id;
if(messId===id){
tempVar.splice(i,1);
var newElement = {
id:data.updates[i][1],
date:data.updates[i][4],
out:e.indexOf('outbox')<0?0:1,//ucx - 1, BxoD = 0
user_id:(data.updates[i][3]>2000000000?data.updates[i][3]-2000000000:use.updates[i][3]),
read_state:e.indexOf('unread')<0?1:0,
title:data.updates[i][5],
body:data.updates[i][6]
};
if(typeof(data.updates[i][7].emoji)==='string')newElement['emoji']=1;
if(data.updates[i][3]>2000000000){newElement['chat_id']=data.updates[i][3]-2000000000;
newElement['from_id']=data.updates[i][7].from;
}
tempVar.unshift(b);
cVar = true;
}
}
if(!cVar){
tempVar.pop();
tempVar.unshift(b);
}
localStorage.setItem('m',JSON.stringify(abcabc));
}else{a.push(b);}