AKA (also known as)
JavaScript ES6 Cheetsheet: AKA (also known as)
Categories:
Imports AKA
// ES6
import 'helpers'
// AKA
require('./helpers');
// ES6
import Express from 'express';
// AKA
const Express = require('express').default
conse Express = require('express');
// ES6
import { indent } from 'helpers';
// AKA
const indent = require('···').indent
// ES6
import *as Helpers from 'helpers';
// AKA
const Helpers = require('./helpers');
// ES6
import { indentSpaces as indent } from 'helpers'
// AKA
const indent = require('./helpers').indentSpaces
Exports AKA
// ES6
export default function () { }
// AKA
module.exports.default = function () { }
// ES6
const User = {
name: 'KJ',
age: 18,
}
export default User;
// AKA
module.exports = User;
module.exports.default = User;
// ES6
export function mymethod () { ··· }
// AKA
module.exports.mymethod = ···
// ES6
export const pi = 3.14159
// AKA
module.exports.pi = ···
// ES6
const user_name = 'KJ';
const user_age = 18;
const User = {
user_name,
user_age,
};
export User;
// AKA
export {
user_name,
user_age,
};
// AKA
module.exports = User;
module.exports = {
user_name,
user_age,
};
module.exports = {
user_name: user_name,
user_age: user_age,
}
// ES6
const hello = '你好';
const bye = '再見';
export {
hello,
bye,
}
// AKA
module.exports = { hello, bye }
module.exports = {
hello: hello,
bye: bye
}