Skip to content

Instantly share code, notes, and snippets.

View WebTarantul's full-sized avatar

Taras Kapusta WebTarantul

View GitHub Profile
@WebTarantul
WebTarantul / Безопасная_проверка_на_наличие.js
Created March 27, 2019 16:23
Безопасная проверка на наличие
// это безопасная проверка на наличие
if (typeof DEBUG !== "undefined") {
console.log( "Debugging is starting" );
}
// =====================
if (typeof atob === "undefined") {
atob = function() { /*..*/ };
}
// =======================
if (window.DEBUG) {
@WebTarantul
WebTarantul / module templates.js
Created March 26, 2019 10:00
Module templates and description
function CoolModule() {
var something = "cool";
var another = [1, 2, 3];
function doSomething() {
console.log( something );
}
function doAnother() {
console.log( another.join( " ! " ) );
@WebTarantul
WebTarantul / OOP наследование.js
Last active April 1, 2019 19:43
OOP наследование
function Person (name) {
this.name = name;
this.sayName = function () {
return 'Hi, I am ' + this.name;
};
}
var adam = new Person('Adam');
@WebTarantul
WebTarantul / OOP- prototype object.js
Created March 22, 2019 08:41
OOP- prototype object
function A() {}
A.prototype.x = 10;
a = new A();
console.log(a.x); //10
console.log(a.y); //undefined
A.prototype.y = 20;
console.log(a.y); //20
/*То есть при таком подходе A.prototype.<свойство> добавления свойств в прототип
function CustomValidation() { }
CustomValidation.prototype = {
// Пустой массив сообщений об ошибках
invalidities: [],
// Метод, проверяющий валидность
checkValidity: function(input) {
var validity = input.validity;
Множественные курсоры в Visual Studio Code
1) Добавить множественные курсоры ко всем вхождениям выделенного текста (CTRL+SHIFT+L)(ALT+f3)(CTRL+F2)
2) Отменить последнюю операцию курсора (CTRL+U)
Функции поиска в Visual Studio Code
1) Поиск файла (CTRL + P)(CTRL+F2)
2) Поиск символа (CTRL + T)(CTRL+F2)
3) Поиск локального символа (CTRL + SHIFT + O)(CTRL+F2)
4) Поиск по ссылке (SHIFT + F12)
@WebTarantul
WebTarantul / test.html
Created November 4, 2018 12:37
KeyboardEvent Value
<!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>Document</title>
</head>
<style>
html {
@WebTarantul
WebTarantul / random Value From Array
Last active February 5, 2019 15:33
Рандомный item масива
function randomValueFromArray(array){
return array[Math.floor(Math.random()*array.length)];
}
@WebTarantul
WebTarantul / map.js
Created August 6, 2018 18:06
Случайная длина масива
// случайная длина масива
var getRandomLengthArray = function(array){
return array.slice(getRandomNumber(0,array.length));
}
@WebTarantul
WebTarantul / map.js
Created August 6, 2018 17:50
shuflfe array
// премешивание масива
function shuffle(arr){
var j, temp;
for(var i = arr.length - 1; i > 0; i--){
j = Math.floor(Math.random()*(i + 1));
temp = arr[j];
arr[j] = arr[i];
arr[i] = temp;
}
return arr;