Unexpected block statement surrounding arrow body
The block statement isn’t needed for a single expression. this.state.todos.filter(filterTodo => filterTodo !== todo);
The block statement isn’t needed for a single expression. this.state.todos.filter(filterTodo => filterTodo !== todo);
Using rest/spread with objects is a separate proposal, which you can read about here. A proposal doesn’t get accepted for the yearly ES release unless it reaches stage 4, and it is currently stage 3. It may make it into ES2018. If you want to use it now, you’ll have to use a transpiler like … Read more
Using ({}) is to destructure the arguments and => () is an implicit return equivalent to => { return ()} and ( only serves to disambiguate between the start of an object and the opening braces of a function body and would generally be used when you have a multiline return value. You could simply … Read more
JavaScript modules are evaluated asynchronously. However, all imports are evaluated prior to the body of module doing the importing. This makes JavaScript modules different from CommonJS modules in Node or <script> tags without the async attribute. JavaScript modules are closer to the AMD spec when it comes to how they are loaded. For more detail, … Read more
You can’t directly do it, looking at the specs show us that the value can be set, but not over-written (such is the standard definition of a constant), however there are a couple of somewhat hacky ways of unsetting constant values. Using scope const is scoped. By defining the constant in a block it will … Read more
I can see three ways around this: Use template strings like they were designed to be used, without any format function: console.log(`Hello, ${“world”}. This is a ${“test”}`); // might make more sense with variables: var p0 = “world”, p1 = “test”; console.log(`Hello, ${p0}. This is a ${p1}`); or even function parameters for actual deferral of … Read more
import is a part of ECMAScript 2015 (ES6) standard and as Amit above mentioned it is not currently implemented natively in Nodejs. So you can use transpiler like babel to run your es6 script npm install babel An example based on this answer app.js import {helloworld,printName} from ‘./es6’ helloworld(); printName(“John”); es6.js module.exports = { helloworld: … Read more
Two things: first, Array.find() returns the first matching element, undefined if it finds nothing. Array.filter returns a new array containing all matching elements, [] if it matches nothing. Second thing, if you want to match 4,5, you have to look into the string instead of making a strict comparison. To make that happen we use … Read more
V8, the JavaScript engine in Chrome, had TCO support for a while, but as of this updated answer (November 2017) it no longer does and as of this writing, there is no active development on TCO in V8, and none is planned. You can read the details in the V8 tracking bug for it. TCO … Read more