Last active
October 29, 2015 13:26
-
-
Save cristopher-rodrigues/58e8c685eb87beb76321 to your computer and use it in GitHub Desktop.
JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* LET: scope vars */ | |
let foo = "bar"; | |
console.log(foo); | |
if(foo.includes("bar")){ | |
let inc = true; | |
} | |
console.log(inc); | |
/*CONST: constants vars */ | |
const PI = 3.14; | |
console.log(PI); | |
const PI = 3.11; //ERR | |
console.log(PI); | |
//- when try let or var dont work | |
let PI = 123; | |
console.log(PI); | |
var PI = 123; | |
console.log(PI); | |
/* Template String: Define string with mult lines */ | |
console.log("dont | |
work"); | |
console.log(`YEAAAAAH, | |
work`); | |
/* Template String (INTERPOLATION): string-mult-line with VARS/LETS etc.. */ | |
console.log(`YEAAAAAH, | |
work`); | |
let foo = "bar"; | |
console.log(`FOOOO!, | |
${bar} | |
`); | |
/* Repeat method on String */ | |
console.log(`${NaN.toString().repeat(10)} Batman!!!`); | |
/* Contains (DEPRECATED) -> Includes ~YEAH~ */ | |
console.log(`${NaN.toString().repeat(1).includes("NaN")}`); | |
console.log(`${NaN.toString().repeat(1).includes("naN")}`); //CASE-SENSITIVE | |
/* IncludesORstartsWith */ | |
console.log(`${NaN.toString().repeat(1).startsWith("NaN")}`); | |
console.log(`${NaN.toString().repeat(1).startsWith("naN")}`); //CASE-SENSITIVE | |
/* News NUMBER/MATH functions */ | |
//- Soon | |
//- BUT ~see~ http://www.2ality.com/2015/04/numbers-math-es6.html | |
/* ARROY => FUNCTIONS */ | |
var plus = param => param + 1; //single PARAM | |
console.log(plus(1)); | |
var sum = (n1, n2) => n1+n2; | |
console.log(sum(1,1)); //N PARAMS | |
var hw = () => "Hello Word"; | |
console.log(hw()); //Not PARAM(s) | |
var foo = (bar) => { | |
return `Hello Word ~${bar}~`; | |
}; | |
console.log(foo("bar")); //With BodyContFn | |
/* ARROW bind this */ | |
//- Soon | |
/* Class */ | |
class Animal { | |
constructor(name) { | |
this.name = name; | |
} | |
speak() { | |
console.log(`${this.name} makes a noise.`); | |
} | |
} | |
let ane = new Animal("Ane"); | |
ane.speak(); | |
class Dog extends Animal { | |
speak() { | |
console.log(`${this.name} barks.`); | |
} | |
} | |
let bob = new Dog("Bob"); | |
bob.speak(); | |
/* Simple module ~without_loader~ */ | |
//- baz.js | |
let baz = 'baz'; | |
export default baz; | |
//another.js | |
import baz from "baz"; | |
//- Try module in module and named your module | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment