Стрелка=>
ничего не привязывает. У функции просто нетthis
.
При получении значенияthis
– оно, как обычная переменная, берётся из внешнего лексического окружения.
const obj = {
w() {
console.log('w', this);
},
x: function () {
console.log('x', this);
},
y: this,
z: () => {
console.log('z', this);
},
};
obj.w(); // obj
obj.x(); // obj
console.log('y', obj.y); // Window
obj.z(); // Window
this
тот же, что и снаружи:const a = this; // Window
const obj = {
b: this, // тоже Window
}
a === obj.b // true
<div id="test">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci alias aliquam est fugit mollitia nisi quam qui! Aliquam aliquid consequatur dolorem ea, expedita ipsam laborum, mollitia praesentium, quidem sed voluptas?</div>
<style>
#test {
color: red;
}
#test:hover {
color: green;
transition: color 3s ease;
}
</style>
#test {
color: black;
transition: color 1s ease;
}
#test:hover {
color: red;
transition: color 5s ease;
}
type
:type ResponseStatus = "error" | "success";
intefcace
:interface ApiResponse {
status: ResponseStatus;
}
type
:namespace Api {
type Status = "error" | "success";
type Response = {
status: Status;
};
}
package.json
(npm init -y
). В приведённом Вами коде используются ES6-импорты (ESM-импорты), которые сразу не будут работать в Node.js, т.к. в нём используются CommonJS-импорты. Для решения данной проблемы у Вас есть два пути:"type": "module"
в package.json
:{
...
"type": "module",
...
}
- import * as crypto from 'crypto';
+ const crypto = require('crypto');
$ node .
cVoADkhcldK+mYC3Id5vhkxOr4NwVspTcgF56RiRG0CzcnOcBwcELKi1YnBNySmZugpjJNHuCU7ePjwVadqfAw==
pointer-events: none
. Вот и все. postsFile = open('posts.txt','r+') # Открываем файл на чтение и запись
posts = postsFile.read().splitlines() # Читаем файл и помещаем строки в список posts
у вас будет подключение к базе данных, создание таблицы, если надоpostsFile.writelines(url+'\n') # И ссылку записываем в файл posts.txt
"use strict";
const {src, dest} = require("gulp");
const gulp = require("gulp");
const gulpCopy = require('gulp-copy');
const outputPath = "dist/";
var path = {
build: {
html: "dist/",
images: "dist/"
},
src: {
html: "src/*.html",
images: ['src/img/**/*.*']
}
}
function images() {
return src(path.src.images)
.pipe(gulpCopy(outputPath, {prefix: 1}))
.pipe(dest(path.build.images));
}
const build = gulp.series(images);
exports.images = images;
exports.default = build;
У меня чистый JS и PHP с фреймворком Laravel.Во первых - неизвестно сколько кода и какой функционал у вас в проекте. Естественно инструмент выбирают под задачу, а не наоборот.
element.hasAttribute('maxlength')
element.setAttribute('maxlength', 20)
document.querySelectorAll('input[type=password]')
forEach()
maxlength
;