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 fun(…input){ | |
let sum = 0; | |
for(let i of input){ | |
sum+=i; | |
} | |
return sum; | |
} | |
console.log(fun(1,2)); //3 | |
console.log(fun(1,2,3)); //6 | |
console.log(fun(1,2,3,4,5)); //15 |
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 fun(a, b){ | |
return a + b; | |
} | |
console.log(fun(1, 2)); // 3 | |
console.log(fun(1, 2, 3, 4, 5)); // 3 |
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 fun(a, b){ | |
return a + b; | |
} | |
console.log(fun(1, 2)); // 3 | |
console.log(fun(1, 2, 3, 4, 5)); // 3 |
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 arr = [1,2,3]; | |
let arr2 = [4,5]; | |
arr = [...arr,...arr2]; | |
console.log(arr); // [ 1, 2, 3, 4, 5 ] |
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 arr = [1,2,3]; | |
let arr2 = [4,5]; | |
arr = arr.concat(arr2); | |
console.log(arr); // [ 1, 2, 3, 4, 5 ] |
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 {port, getAccounts} from 'module' | |
console.log(port) // 3000 |
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
export var port = 3000 | |
export function getAccounts(url) { | |
... | |
} |
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 baseModel { | |
constructor(options = {}, data = []) { // class constructor | |
this.name = 'Base' | |
this.url = 'http://azat.co/api' | |
this.data = data | |
this.options = options | |
} | |
getName() { // class method | |
console.log(`Class name: ${this.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
function calculateTotalAmount (vip) { | |
var amount = 0 // probably should also be let, but you can mix var and let | |
if (vip) { | |
let amount = 1 // first amount is still 0 | |
} | |
{ // more crazy blocks! | |
let amount = 100 // first amount is still 0 | |
{ | |
let amount = 1000 // first amount is still 0 | |
} |
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 calculateTotalAmount (vip) { | |
var amount = 0 | |
if (vip) { | |
var amount = 1 | |
} | |
{ // more crazy blocks! | |
var amount = 100 | |
{ | |
var amount = 1000 | |
} |
NewerOlder