class App extends React.Component{
state = {
title: 'List',
arr: [
'simon','dima','kosty'
]
}
ren = ({target}) => {
alert(target.textContent);
}
render(){
return(
<div>
<h1>{this.state.title}</h1>
<ol>
{this.state.arr.map(
(list, key) =>
<li onClick={this.ren} key={key}>{list}</li>
)}
</ol>
</div>
);
}
}
ReactDOM.render(
<App />,
document.getElementById('root')
);
var obj = new {Id = 15, Name = "adam"};
var str = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
Person p = Newtonsoft.Json.JsonConvert.DeserializeObject<Person>(str);
System.Console.WriteLine($"{p.Id}, {p.Name}");
class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
Uncaught ReferenceError: $ is not defined
at pen.js:15:10
import { Component, OnDestroy, OnInit } from '@angular/core';
import 'rxjs/add/operator/takeUntil';
import { Subject } from 'rxjs/Subject';
import { MyThingService } from '../my-thing.service';
@Component({
selector: 'my-thing',
templateUrl: './my-thing.component.html'
})
export class MyThingComponent implements OnDestroy, OnInit {
private ngUnsubscribe: Subject<void> = new Subject<void>();
constructor(
private myThingService: MyThingService,
) { }
ngOnInit() {
this.myThingService.getThings()
.takeUntil(this.ngUnsubscribe)
.subscribe(things => console.log(things));
this.myThingService.getOtherThings()
.takeUntil(this.ngUnsubscribe)
.subscribe(things => console.log(things));
}
ngOnDestroy() {
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
}
}
const random = (min, max) => Math.floor(Math.random() * (max - min) + min),
offerTitles = [
"Большая уютная квартира",
"Маленькая неуютная квартира",
"Огромный прекрасный дворец",
"Маленький ужасный дворец",
"Красивый гостевой домик",
"Некрасивый негостеприимный домик",
"Уютное бунгало далеко от моря",
"Неуютное бунгало по колено в воде"
],
shuffledOfferTitles = [...offerTitles].sort(() => Math.random() > 0.5),
types = ["flat", "house", "bungalo"],
checks = ["12:00", "13:00", "14:00"],
features = ["wifi", "dishwasher", "parking", "washer", "elevator", "conditioner"];
const result = [...Array(8).keys()].map((id) => ({
author: {
avatar: `img/avatars/user0${id + 1}.png`
},
offer: {
title: shuffledOfferTitles[id],
address: "location.x, location.y",
price: random(1000, 1000000),
type: types[random(0, types.length)],
rooms: random(1, 5),
guests: random(1, 9),
checkin: checks[random(0, checks.length)],
checkout: checks[random(0, checks.length)],
features: ((rnd) => features.slice(random(0, rnd), random(rnd, features.length)))(random(0, features.length -1)),
description: "",
photos: []
},
location: {
x: random(300, 900),
y: random(100, 500)
}
}));
using System;
public abstract class Country
{
public string NameOfVariable { get; set; }
protected Country(string name) {
NameOfVariable = name;
}
}
public class Russia : Country
{
public Russia(string name) : base(name) {}
}
public class Italy : Country
{
public Italy(string name) : base(name) {}
}
public class Test
{
public static void Main()
{
Info(new Russia("Hello From Russia"));
Info(new Italy("me gusta!"));
}
public static void Info(Country country)
{
string text = country.NameOfVariable;
Console.WriteLine(text);
}
}
Hello From Russia
me gusta!
И для чего нужно _dogName, если есть просто dogName?
const blackList = ['Мурзик', 'Васька', 'Эпифантий'];
// ...
set dogName(value)
{
if (!value || !_.isString(value)) {
throw new Error('value must be a string!') ;
}
if (blackList.includes(value) {
throw new Error('wrong value!') ;
}
this._dogName = value;
}