Skip to content

Instantly share code, notes, and snippets.

View RinatValiullov's full-sized avatar
👷‍♂️
Looking for a job

Rinat Valiullov RinatValiullov

👷‍♂️
Looking for a job
View GitHub Profile
@RinatValiullov
RinatValiullov / nativeJavaScript.js
Created October 25, 2018 15:39 — forked from alexhawkins/nativeJavaScript.js
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests
@RinatValiullov
RinatValiullov / forlooptask.md
Last active February 16, 2019 11:27
Classic task about for loop and setTimeout

What needs to be done to get the correct sequence of numbers from 0 to 4 inclusive?

for(var i = 0; i < 5; i++) {
    setTimeout(function() {
        console.log(i);
    }, 0)
}

@RinatValiullov
RinatValiullov / array_method.md
Last active February 28, 2019 21:30
My Custom Snippets
{
    "Array Method": {
        "prefix": "arrm",
        "body": [
            "${1|forEach,map,reduce,filter,some,every,find,flat|}((${2:element}, ${3:index}) => {",
            "\t$4",
            "})",
            ""
 ],
@RinatValiullov
RinatValiullov / minification.md
Created April 24, 2019 06:55 — forked from gaearon/minification.md
How to Set Up Minification

In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.

Here's one way to set it up:

  1. Install Node.js
  2. Run npm init -y in your project folder (don't skip this step!)
  3. Run npm install terser

Now, to minify a file called like_button.js, run in the terminal:

@RinatValiullov
RinatValiullov / importSL.html
Last active May 19, 2019 16:51
Testing import the external code to SoloLearn
<div>Some external code</div>
[
{
color: "Goldenrod"
},
{
color: "Green"
},
{
color: "Khaki"
},
@RinatValiullov
RinatValiullov / feature_detect_es_modules.js
Created June 14, 2019 04:38 — forked from ebidel/feature_detect_es_modules.js
Feature detect ES modules: both static import and dynamic import()
<!--
Complete feature detection for ES modules. Covers:
1. Static import: import * from './foo.js';
2. Dynamic import(): import('./foo.js').then(module => {...});
Demo: http://jsbin.com/tilisaledu/1/edit?html,output
Thanks to @_gsathya, @kevincennis, @rauschma, @malyw for the help.
-->
@RinatValiullov
RinatValiullov / deepClone.js
Created July 26, 2019 15:34
Creates a deep clone of an object.
const deepClone = obj => {
let clone = Object.assign({}, obj);
Object.keys(clone).forEach(
key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])
);
return Array.isArray(obj) && obj.length
? (clone.length = obj.length) && Array.from(clone)
: Array.isArray(obj)
? Array.from(obj)
: clone;
@RinatValiullov
RinatValiullov / random-pool.js
Created October 13, 2019 09:37
Get pool of random numbers
let generateRandomNumbers = (quantity) => {
let randomValues = {
[Symbol.iterator]: function() {
return {
next: function() {
return { value: ~~(Math.random() * quantity) };
}
}
}
};
@RinatValiullov
RinatValiullov / old_syntax.js
Created November 15, 2019 08:39
For translation of article "Performance of JavaScript optional chaining" - https://bit.ly/33Pg0uv
foo && foo.bar && foo.bar.baz && foo.bar.baz.qux