var getAdder = function () { var res = 0; return function(x) { res += x; return res; } };
var sum = getAdder();
sum(1); // 1
sum(3); // 4
var sum2 = getAdder(); // два независимых сумматора
sum2(1); //1
sum2(3); // 4var adder2 = new Function('x', 'var result = adder.last? adder.last + x : x; adder.last = result; return result');
adder2(2); //ReferenceError: adder is not definedvar a = [ { id: 0 }, { id: 1 }, { id: 2 } ];
for(var i = 0; i != a.length; ++i)
{
var el = a[i];
setTimeout(function() {
console.log('timeout',el);
},100);
}timeout Object { id: 2 }
timeout Object { id: 2 }
timeout Object { id: 2 }
var a = [ { id: 0 }, { id: 1 }, { id: 2 } ];
var createCB = function(e){
return function() {
console.log('timeout',e);
};
};
for(var i = 0; i != a.length; ++i)
{
var el = a[i];
setTimeout(createCB(el),100);
}timeout Object { id: 0 }
timeout Object { id: 1 }
timeout Object { id: 2 }
function render($templateName, $templateData)
{
extract($templateData,EXTR_SKIP);
ob_start();
require($templateName);
return ob_get_clean();
}$templateVars = array();
$templateVars['data'] = array();
$templateVars['content'] = array(); // итд
while ($templateVars['data'][] = mysqli_fetch_assoc($result));
$html = render('templates/templ1.php',$templateVars);
echo $html;<?php for($i = 0; $i != count($data); ++$i) { $row = $data[$i]; ?>
<div class='panel panel-default'>
<div class='panel-heading'><h4><?=$row['title']?></h4></div>
<div class='panel-body story'>
<?=$content[0]?>
<div class='clearfix'></div>
<hr>
<div class='row'>
<p class='col-xs-6 text-left'>
<a href='post.php?id=<?=$row['id']?>'>Прочитать</a>
</p>
<p class='col-xs-6 text-right'>
<span class='glyphicon glyphicon-comment'><?=$row['countcomments']?></span>
</p>
</div>
</div>
</div>
<?php } ?>scope.$parentmyModule.directive("positioning", function($http, $compile) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var height;
$(element).load(function(){
height = $(this).height();
});
return scope.$watch((function() {
return height;
}), function(newValue, oldValue) {
return console.log(newValue);
});
}
};
}); div.food_box_scroll_item > div.btn_food_box_scroll > a.but_call_min
$('.but_call_min').click(function(){
console.log('Selected:',$(this).closest('.food_box_scroll_item').find(".value_number_of_servings").val());
});/*Add to cart*/
$(document).ready(function() {
$(".food_box_scroll_item .btn_food_box_scroll .but_call_min").click(function(){
prod_id = $(this).attr("rel");
count_this = parseInt($(this).closest('.food_box_scroll_item').find(".value_number_of_servings").val());
// addToCart(prod_id, count_this);
// alert(count_this); // - так плохо
console.log(count_this); // - так хорошо
});
}); if( $( '#blockID' ).length == 0
|| $( '#blockID' ).css( "display" ) == 'none'
|| parseFloat($( '#blockID' ).css( "opacity" )) != 1.0)
{
// Реклама удалена
} <Directory "%ssitedir%/*">
AllowOverride All
Options -MultiViews +Indexes +FollowSymLinks +IncludesNoExec +Includes +ExecCGI
<LimitExcept GET POST HEAD >
Require all denied
</LimitExcept>
</Directory><Directory "%ssitedir%/*">
AllowOverride All
Options -MultiViews +Indexes +FollowSymLinks +IncludesNoExec +Includes +ExecCGI
<LimitExcept GET POST HEAD OPTIONS DELETE>
Require all denied
</LimitExcept>
</Directory>Order.query({id: 'all'}, function(orders) {
$scope.orders = orders;
console.log('get data from server');
$scope.$broadcast('dataloaded');
});.directive('orderDrct', ['$compile',
function ($compile) {
return {
restrict: 'A',
link: function (scope, element) {
scope.$on('dataloaded', function ()
{
// Ваш код
console.log('end of directive');
});
}
};
}
]);void (*gFunPtr)(int) = (void(*)(int)) ((int*)f+3); // Глобальная переменнаяvoid foo2(int a)
{
void (*fptr)(int) = gFunPtr;
...
}mov eax,[000403024]
...6C10400000401060(адрес функции f) + С (3 * sizeof int)