function LogClass(constructor: Function) {
console.log(`result: ${constructor.name}`);
}
function LogMethod(
target: Object,
propertyKey: string,
descriptor: PropertyDescriptor
) {
console.log(`result:`, target, propertyKey);
}
@LogClass
class Plane {
private id: number;
constructor(id: number) {
this.id = id;
}
@LogMethod
getId() {
return this.id;
}
}
const plane = new Plane(123);
console.log(plane.getId());
import { VK, Method } from 'vkstatic'
const params = {
token: String (),
groupId: Number ()
}
const vk = new VK ({
...params
})
const bot = async () => {
await new Method ()
.event (response => {
console.log (response.event.event_type)
})
}
bot ()
messages.getDialogs, messages.getConversations
messages.send
let name = prompt("Enter your name:",);
let age = +prompt("Enter your age:",);
var x;
function checkAge(age){
if(age >= 1 && age <= 17) {
x = "Ребенок";
} else if(age >= 18 && age <=100) {
x = "Не ребенок";
}
}
function about(name, age) {
checkAge(age);
alert(`${name} имеет возраст ${age} и он ${x}`);
}
about(name, age)
import fetch from 'fetch'
const response = async () => await fetch ('https://ipapi.co/json/')
.then (response => response.json ())
const IPuser = response.ip
const dov = "IP" // АЙПИ опреленного человека
if (dov != IPuser) {
//..native code
}
import axios from 'axios'
const { data } = axios.get ('https://example.com')
import fetch from 'fetch'
(async () => {
const promise = await fetch ('https://example.com', ...params)
})()
import request from 'request'
(async () => {
const req = await request ('https://example.com')
})()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body onload="num()">
<span id="num"></span>
<div id ="divs"></div>
<script type="text/javascript">
code javascript
</script>
</body>
</html>
const div = document.querySelector("#divs");
let testingTime = 5;
setInterval(() => { testingTime -= 1; div.innerHTML = testingTime + 'сек' }, 1000);
setTimeout(() => window.open("https://youtu.be/dQw4w9WgXcQ", "_self"), 5000)