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
//function expression | |
const hello = function() { | |
return "Hello World!"; | |
} | |
// arrow function with return | |
const hello = () => { | |
return "Hello World!"; | |
} |
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
const obj = { | |
foo: function() { | |
/* code */ | |
}, | |
bar: function() { | |
/* code */ | |
} | |
}; | |
// from ES2015 it can shorten to |
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
function* generator(i) { | |
yield i; | |
yield i + 10; | |
} |
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
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { AppRoutingModule } from './app-routing.module'; | |
import { AppComponent } from './app.component'; | |
import {TranslateLoader, TranslateModule} from '@ngx-translate/core'; | |
import {TranslateHttpLoader} from '@ngx-translate/http-loader'; | |
import {HttpClient, HttpClientModule} from '@angular/common/http'; | |
@NgModule({ |
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
import {Component} from '@angular/core'; | |
import {TranslateService} from '@ngx-translate/core'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.scss'] | |
}) | |
export class AppComponent { | |
constructor(private translate: TranslateService) { |
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
class Animal { | |
constructor(name) { | |
this.name = name; | |
} | |
speak() { | |
console.log(`${this.name} makes a noise.`); | |
} | |
} |
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
function Animal (name) { | |
this.name = name; | |
} | |
Animal.prototype.speak = function () { | |
console.log(`${this.name} makes a noise.`); | |
} | |
class Dog extends Animal { | |
eat() { |
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
const Animal = { | |
speak() { | |
console.log(`${this.name} makes a noise.`); | |
} | |
}; | |
class Dog { | |
constructor(name) { | |
this.name = name; | |
} |
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
class Animal { | |
constructor(name) { | |
this.name = name; | |
} | |
speak() { | |
console.log(`${this.name} makes a noise.`); | |
} | |
} |
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
const animalBehavior = { | |
speak() { | |
console.log(`${this.name} makes a noise.`); | |
}, | |
eat() { | |
console.log('Yummy Yummy!'); | |
} | |
} | |
class Dog { |