basic Flashcards
what is mostly use const or let?
const.
when should you use let?
when the value is going to change
playground to practice js?
jsbin.com
how do you write a normal js function ?
function myFunc() { }
assing an arrow function to a variable?
const myFunc = () => { }
what can you do with const process = (name) => { }?
remove parenthesis in the single argument
when you decalre a function in js do you have to declare the argument type?
no.
if your arrow function does not take arguments can you go const work = => {} ?
no you have to use const work = () => {}
if the body of your arrow function only has a return statement what can you do?
remove the {}. e,g,, const multiply (number) => number * 2;
even better const multiply number => number * 2;
what are default exports? and imports
when you export an object in your .js by saying at the end export default person
This makes the import for only the default, i.e.,
import prsn from ‘./person.js’
what are name imports? and exports
name exports: export const clean = () => {...} export const baseData = 10; notice there's no default keyword. the import has to go like: import {baseData } from './utility.js' or import {baseData, clean} from './utility'
others syntax’s allowed for import?
import {smth as Smth} from ‘./utility.js’
import * as bundled from ‘./utility.js’
create a class called Person in js
class Person { constructor() { this.name = 'Max'; }
printName() { console.log(this.name); } }
instanciate class Person and call method printName
const p = new Person(); p.printName();
create a class Human and make Person inherit from it
class Human { constructor() { this.gender = 'M'; printGender() { console.log(this.gender); } }
class Person extends Human { constructor() { super(); this.name = 'Max'; } printName() { console.log(this.Name); } }
what does ES6 means?
ECMA Script 6 (European Computer Manufacturers Association)
what is the official name of JavaScript?
ECMA Script
what is Babel?
is a transpiler, that does not compile but translate from one language to other. Babel translate from ES6 to normal Javascript