NaN !== NaN // true
isNaN(undefined); // true
isNaN({}); // true
isNaN('test'); // true
$('.f1').on('change', function(e) => {
var value = $(e.currentTarget).val();
})
$(document).find('.form-element').on('change', e => console.log($(e.currentTarget).val()));
<Route path="/post/:postId" component={Post}/>
const Post = ({ match, postsMap }) => {
const post = postsMap[match.params.postId];
return (
<div>
<h1>{post.title}</h1>
<p>{post.body}</p>
</div>
}
<List>
{postsList.map(post => (
<Link to={`/post/${post.id}`} key={post.id}>{post.title}</Link>
))}
</List>
import { connect } from 'react-redux';
import { inputIdeaHandle } from '../actions';
const mapDispatchToProps = {
inputIdeaHandle,
};
export default connect(null, mapDispatchToProps)(Dashboard);
changeHandle = e => {
const { value } = e.target;
this.props.inputIdeaHandle(value);
};
const array = Array.prototype.slice.call(nodeList);
const array = Array.from(nodeList)
const array = [...nodeList];
npm install eslint --save-dev
{
"extends": [
"airbnb",
"prettier",
],
"plugins": [
"prettier"
],
"parser": "babel-eslint",
"rules": {
/* тут пишите правила,
* так же при использовании конфигов,
* вам скорей всего захочется какие-то
* правила, используемые в них, отключить,
* это можно сделать тут
*/
}
}
const str = "<div class='abc'></div><div class='abc'></div>";
const array = $(str);
array.each((_, el) => console.log(el));
// результат
// <div class="abc"></div>
// <div class="abc"></div>
const human = {
planet: 'Earth',
}
const tom = Object.create(human);
tom.name = 'Tom';
tom.age = 32;
tom.country = 'UK';
console.log(tom.planet);
// => Earth
const human = {
planet: 'Earth',
}
const tom = Object.create(human);
tom.name = 'Tom';
tom.age = 32;
tom.country = 'UK';
human.planet = 'Mars';
console.log(tom.planet);
// => Mars
const human = {
planet: 'Earth',
}
const tom = Object.create(human);
tom.name = 'Tom';
tom.age = 32;
tom.country = 'UK';
tom.planet = 'Jupiter';
human.planet = 'Mars';
console.log(tom.planet);
// => Jupiter
console.log(human.planet);
// => Mars
const human = {
planet: 'Earth',
}
const tom = $.extend({}, human);
tom.name = 'Tom';
tom.age = 32;
tom.country = 'UK';
const arr1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
const arr2 = ['b', 'd', 'f'];
const result = arr1.filter(el => !arr2.includes(el));
// результат ['a', 'c', 'e', 'g']
const arr1 = [{name: 'Carl', age: 32}, {name: 'Sally', age: 24}];
const arr2 = [{name: 'Carl', age: 32}];
const result = arr1.filter(x => !arr2.some(y => x.name === y.name));
// результат [{name: 'Sally', age: 24}]
const compareObjects = (obj1, obj2) => {
for (let p in obj1){
if (Object.prototype.hasOwnProperty.call(obj1, p)) {
if(obj1[p] !== obj2[p]){
return false;
}
}
}
for(let p in obj2){
if (Object.prototype.hasOwnProperty.call(obj2, p)) {
if (obj1[p] !== obj2[p]) {
return false;
}
}
}
return true;
};
const arr1 = [{name: 'Carl', age: 32}, {name: 'Sally', age: 24}];
const arr2 = [{name: 'Carl', age: 32}];
const result = arr1.filter(x => !arr2.some(y => compareObjects(x, y)));
// результат [{name: 'Sally', age: 24}]
Use babel-plugin-syntax-dynamic-import on the client.
Use babel-plugin-dynamic-import-node on the server.
function a() {
var c = 2;
function b() {
return c++;
};
return b;
}
var d = a();
alert(d()); // 2
alert(d()); // 3
function b() {
return c++;
};
function a() {
var c = 2;
function b() {
return c++;
};
return b;
}
var d = a();
var e = a();
alert(d()); // 2
alert(d()); // 3
alert(e()); // 2
alert(d()); // 4
alert(d()); // 5
alert(e()); // 3