function shuffle(arr) {
for (let i = arr.length - 1; i > 0; --i) {
const pos = Math.floor(Math.random() * (i + 1));
const t = arr[pos];
arr[pos] = arr[i];
arr[i] = t;
}
return arr;
}
const newArr = shuffle(imagesData.slice()); // новый перемешанный, imagesData не поменялось
const newArr2 = shuffle(imagesData); // перемешали imagesData, присвоили в newArr2
globalFunc.[[Scope]] = window;
interface IAnimal {
name: string;
say: () => string;
}
abstract class Animal implements IAnimal {
name: string;
constructor(name: string) {
this.name = name;
}
say() {
return `${this.name} says ${this.phrase}`;
}
protected abstract phrase: string;
}
class Cat extends Animal {
protected get phrase() { return 'm'; }
}
const c = new Cat('q');
console.log(c.say());
const bounds: TRange = [32400, 54000];
// getSpaceRanges(bounds, [
// [35000, 37000],
// [36000, 54000],
// ])
export default const MyItem = React.memo(({ item, setNewItemData }) => {
....
});
let [items, setItems] = useState(myData);
const setNewItemData = useCallback((itemId, data) => {
setItems((items) => {
return items.map(item => {
if (item.id !== itemId) {
return item;
}
return {...item, data}
});
});
}, [setItems]);
const [search,setSearch] = useState(null);
const [search,setSearch] = useState('');