function increaseSalary() {
return new Promise((resolve, reject) => {
let minSalaryEmployee = Promise.resolve().then((employeeData) => {
return { };
});
minSalaryEmployee
.then((data) => {
let newSalary = Promise.reject();
newSalary
.then((newData) => {
resolve(`Ok`);
})
.catch((e) => {
reject(`Error`)
});
})
.catch(reject);
});
}
increaseSalary()
.then(console.log)
.catch(console.error);
function removeItem(id){
return function(e){
...
}
}
render = () => {
const { removeItem, id } = this.props;
return(
<button onClick={removeItem(id)}> Remove item </button>
)
}
const func = (e) => { //.... };
removeItem = (id) => func
const f1 = removeItem(1)
const f2 = removeItem(2)
f1(e)
f2(e)
str.slice(0, 3) + '-'.repeat(Math.max(0, str.length - 3))
// или
str.replace(/(?<=.{3})./g, '-')
// или
Array.from(str, (n, i) => i < 3 ? n : '-').join('')
// или
str.replace(/./g, (m, i) => i < 3 ? m : '-')
// или
str.match(/.{0,3}/) + Array(Math.max(0, str.length - 2)).join`-`
// или
str.substring(0, 3).padEnd(str.length, '-')
const newData = JSON.parse(
JSON.stringify(data),
(key, value) => key === 'value' ? 'new value' : value
);