<script src="assets/js/main.js" type="module"></script>
function isIncludes(string, substring) {
return string.toLowerCase().indexOf(substring.toLowerCase()) !== -1;
}
if (isIncludes(value1, word1) && isIncludes(value2, word2)) {
console.log(word1, ' and ', word2);
}
function Entity(name) {
this.name = name;
}
Entity.prototype.write = function() {
console.log(this.name);
}
var calina = new Entity('calina');
calina.write();
{
message: "Новый объект!"
}
fetch('https://example.com/api')
.then(response => response.json())
.then(json => dispatch(someAction(json)))
.catch(console.log);
const handleFiles = () => {
return async handle => {
let result;
result = 'hello';
return result;
};
};
handleFiles()().then(result => console.log(result)).catch(console.log(e));
const handleFiles = async () => {
let result;
result = 'hello';
return result;
};
handleFiles().then(result => console.log(result)).catch(console.log(e));
class App extends React.Component {
state = {
category: 'business',
items: [],
};
componentDidMount() {
this.fetchData();
}
fetchData() {
axios.get('https://newsapi.org/v2/top-headlines?country=us&category='+this.state.category)
.then(res => {
this.setState({ items: res.data.articles });
});
}
changeCategory = () => {
this.setState(
{ category: 'entertainment' },
this.fetchData,
);
};
render() {
return (
<div className='wrapper'>
<button onClick={this.changeCategory}>CLICK</button>
</div>
);
}
}
<input class="js-search" />
<a class="js-search-link" target="_blank" href="#">Search in Google</a>
var defaultHref = 'https://google.com/search?q=';
var search = document.querySelector('.js-search');
var link = document.querySelector('.js-search-link');
link.setAttribute('href', defaultHref);
search.addEventListener('input', function() {
link.setAttribute('href', defaultHref + search.value.trim().replace(/ +/, '+'));
});