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
| // это безопасная проверка на наличие | |
| if (typeof DEBUG !== "undefined") { | |
| console.log( "Debugging is starting" ); | |
| } | |
| // ===================== | |
| if (typeof atob === "undefined") { | |
| atob = function() { /*..*/ }; | |
| } | |
| // ======================= | |
| if (window.DEBUG) { |
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 CoolModule() { | |
| var something = "cool"; | |
| var another = [1, 2, 3]; | |
| function doSomething() { | |
| console.log( something ); | |
| } | |
| function doAnother() { | |
| console.log( another.join( " ! " ) ); |
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 Person (name) { | |
| this.name = name; | |
| this.sayName = function () { | |
| return 'Hi, I am ' + this.name; | |
| }; | |
| } | |
| var adam = new Person('Adam'); | |
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 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.<свойство> добавления свойств в прототип |
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 CustomValidation() { } | |
| CustomValidation.prototype = { | |
| // Пустой массив сообщений об ошибках | |
| invalidities: [], | |
| // Метод, проверяющий валидность | |
| checkValidity: function(input) { | |
| var validity = input.validity; |
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
| Множественные курсоры в 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) |
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>Document</title> | |
| </head> | |
| <style> | |
| html { |
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 randomValueFromArray(array){ | |
| return array[Math.floor(Math.random()*array.length)]; | |
| } |
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 getRandomLengthArray = function(array){ | |
| return array.slice(getRandomNumber(0,array.length)); | |
| } |
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 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; |