// e. g. let's take some array of numbers
let numbers = [11,55,2,98,115,32,116,48,154];
let biggest = numbers.reduce( (acc, curr) => {
console.table({acc, curr});
return curr > acc ? curr : acc;
});
// console.log(biggest); the biggest number will be 154;
This file contains hidden or 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
/* We can only use binary search if the input array of numbers is already sorted! */ | |
let binarySearch = (target, numbers) => { | |
/* find an apearance of target in numbers */ | |
/* | |
** we have lowLimit and highLimit of our range(numbers) | |
** so starting point is -1 (the 0th index) | |
*/ | |
let lowLimit = -1; |
This file contains hidden or 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
// Simple array | |
const myArray = [4,5,6]; | |
const factoryFunction = (array) => { | |
// The generator's state variable(s) | |
let i = 0; | |
return function generator() { | |
if(i < array.length) { | |
// Compute the new value |
This file contains hidden or 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 randEl( array ) { | |
return array[Math.round(Math.random() * (array.length - 1))] | |
}; | |
const myArray = [1,2,3,4,5,6,7,8,9]; | |
randEl( myArray ); // random element of an myArray |
This file contains hidden or 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 randoms = { | |
[Symbol.iterator]: function() { | |
return { | |
next: function() { | |
// Generate values in range [0..10] | |
return { value: Math.round(Math.random() * 10) }; | |
} | |
}; | |
} | |
}; |
This file contains hidden or 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 getClassOfObject( object ) { | |
if ( object === null ) return "Null"; | |
if ( object === undefined ) return "Undefined"; | |
return Object.prototype.toString.call( object ).slice(8, -1); | |
}; | |
getClassOfObject(null) // "Null" | |
getClassOfObject('string') // "String" | |
getClassOfObject(111) // "Number" | |
getClassOfObject(Object.constructor) // "Function" |
This file contains hidden or 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
// Определяем зависимости в переменных | |
var gulp = require('gulp'), | |
cache = require('gulp-cache'), | |
clean = require('gulp-clean'), | |
stream = require('event-stream'), | |
size = require('gulp-size'), | |
jshint = require('gulp-jshint'), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglify'), | |
minifyCSS = require('gulp-minify-css'), |
This file contains hidden or 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
// Gulp 4 | |
var gulp = require('gulp'); | |
var using = require('gulp-using'); | |
var grep = require('gulp-grep'); | |
var changed = require('gulp-changed'); | |
var del = require('del'); | |
var coffee = require('gulp-coffee'); | |
var less = require('gulp-less'); | |
var coffeelint = require('gulp-coffeelint'); | |
var sourcemaps = require('gulp-sourcemaps'); |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Measuring the Critical Rendering Path</title> | |
<link rel="stylesheet" href="./style.css"> | |
<script src="./script.js" defer></script> | |
</head> |
Синхронизация настроек Sublime Text 3