<ul data-bind="foreach: places ">
<li data-bind="text: $data.businesses[0].name"></li>
</ul>
function reset(obj) {
var defaults = {
'[object Object]': {},
'[object Array]': [],
'[object String]': '',
'[object Boolean]': false,
'[object Number]': 0,
'[object Function]': function() {}
};
for (var key in obj){
if (obj.hasOwnProperty(key)) {
obj[key] = defaults[Object.prototype.toString.call(obj[key])];
}
}
}
var exportInfo = {
format: "json",
url: "/export/json",
size: 0,
items: [1,2,3],
fn: function(x) { return x;},
filename: "export.json"
};
reset(exportInfo);
res.writeHead(200, {
'Access-Control-Allow-Origin': '*',
// 'Access-Control-Allow-Credentials': true
});
var express = require('express'),
cors = require('cors'),
app = express();
app.use(cors());
// или
app.use(cors({
origin: true,
credentials: true
}));
var G = ['iii', 'photographies'],
letter = 'i',
reg = new RegExp(letter + '{3,}', 'i')
for(i=0; i < G.length; i++) {
found = G[i].match(reg);
document.write(letter+' в '+ G[i] + ' = ' + found + '<br>');
}
a[href*=#]
a[href*="#"]
var delay = 1000,
timer;
document.getElementById('text').addEventListener('input', function() {
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(function() {
alert('Можно отсылать')
}, delay);
});
<Button onClick={resetUsers.bind(this)} >Gotcha!</Button>
this.handleAlertDismiss = this.handleAlertDismiss.bind(this);
пишемthis.state.resetUsers = this.state.resetUsers.bind(this);
constructor() {
super(...props);
this.handleAlertDismiss = this.handleAlertDismiss.bind(this);
this.state = {
showModal: true,
resetUsers: this.handleAlertDismiss
};
}
markers[i].addListener('click', (function(i) {
return function() {
markersPopup[i].open(map, markers[i]);
};
})(i));
$('h1').prevAll('img').wrapAll('<div class="group"></div>');
$('h1').nextAll('img').wrapAll('<div class="group"></div>');
var $h1 = $('h1'), methods = ['prevAll', 'nextAll'];
methods.forEach(function(method) {
$h1[method]('img').wrapAll('<div class="group"></div>');
});
import {Component, Inject, NgZone} from 'angular2/core'; // import NgZone
...
constructor(@Inject(UsersService) private UsersService, private zone:NgZone) {
UsersService.users.subscribe(newUsers => {
this.zone.run(()=> {
this.currentUsers = newUsers;
});
});
UsersService.fetchUsers();
}
var book = {
author__1: {
name: 'John',
surname: 'Smith'
},
author__2: {
name: 'John',
surname: 'Smith'
}
};
var max = Object.keys(book).length;
for (var i = 1; i <= max; i++) {
console.log(book['author__' + i].name);
}
$('#addFields').on('click', adminFields.addFields);
$('#addFields').on('click', function() {
adminFields.addFields();
});
$('#addFields').on('click', adminFields.addFields.bind(adminFields));
interface IterableIterator<T> extends Iterator<T> {
[Symbol.iterator](): IterableIterator<T>;
}
class Node {
public id: number;
constructor(id: number){
this.id = id;
}
}
class List {
public nodeAll: Node[];
constructor(nodeAll: Node[]){
this.nodeAll = nodeAll;
}
iterator(): IterableIterator<Node> {
return this.nodeAll[Symbol.iterator]();
}
}
let list = new List([new Node(0), new Node(1), new Node(2)]);
let iterator: IterableIterator<Node> = list.iterator();
for(let node of iterator){
console.log(node.id);
}