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 checkPermission(func) { | |
return function() { | |
if (isAdmin()) return func.apply(this, arguments); | |
console.log('Нет прав'); | |
}; | |
} | |
function isAdmin() { |
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
class User { | |
constructor(name) { | |
this.name = name; | |
} | |
say(msg) { | |
console.log(this.name + ' say: ' + msg); | |
} |
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 animal = { | |
name: 'Animal', | |
}; | |
var rabbit = { | |
type: 'Rabbit', | |
__proto__: animal, | |
}; | |
function RabbitBig() { |
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 Animal(name) { | |
this.name = name; | |
this.speed = 0; | |
} | |
Animal.prototype.run = function(speed) { | |
this.speed += speed; | |
console.log(this.name + ' бежит, скорость ' + this.speed); | |
}; |
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 (top != window) { | |
top.location = window.location; | |
} | |
//https://learn.javascript.ru/clickjacking |
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 basketModule = (function() { | |
var basket = []; // приватная переменная | |
return { // методы доступные извне | |
addItem: function(values) { | |
basket.push(values); | |
}, | |
getItemCount: function() { | |
return basket.length; | |
}, | |
getTotal: 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 module = (function() { | |
var _private = { | |
i: 5, | |
get: function() { | |
console.log('Текущее значение:' + this.i); | |
}, | |
set: function(val) { | |
this.i = val; | |
}, | |
run: 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
import {App, Post} from 'geekhub'; | |
var posts = Post.find; | |
var posts = Post.find(); | |
var posts = Post.find({id: 123}); | |
var posts = Post.find({id: 123}, {id: 34}); | |
var posts = Post.find([{id: 123}, {id: 34}]); | |
var posts = Post.find({id: [123, 456, 65, 8678]}, {id: 34}); | |
var posts = Post.find([{id: [123, 456, 65, 8678]}, {id: 34}]); |
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
* { | |
-moz-osx-font-smoothing: grayscale; | |
-webkit-font-smoothing: antialiased; | |
text-rendering: optimizeLegibility; | |
font-family: helvetica; | |
} | |
body{ | |
line-height: 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
;(function () { | |
function domReady (f) { /in/.test(document.readyState) ? setTimeout(domReady,16,f) : f() } | |
function resize (event) { | |
event.target.style.height = 'auto'; | |
event.target.style.height = event.target.scrollHeight+'px'; | |
} | |
/* 0-timeout to get the already changed text */ | |
function delayedResize (event) { | |
window.setTimeout(resize, 0, event); |