You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import React, { Component } from 'react';
export default App;
touch utils.js
// utils.js
export times(x) {
return x * x;
}
export plusTwo(x) {
return x + 2;
}
import {times, plusTwo} from './utils';
console.log( times(2));
console.log(plusTwo(3));
// utils.js
export default function(x) {
return x * x;
}
// app.js
import k from './utils';
console.log(k(4)); // returns 16
// in util.js
export function times(x) {
return x * x;
}
export function plusTwo(number) {
return number + 2;
}
// in app.js
import { times as multiplication, plusTwo as plus2 } from './util.js';
// default and named import together
import React, { Component } from 'react';
spread operator
const numbers = [1,2,3,4];
const sum = (x, y, z) => {
return x + y + z;
}
console.log(sum(...numbers));