[英]How to transform an array of objects with the same property name into the object in which value is concatenated from values in a given array? JS
[英]How to return an object which same property name and value as a local variable
有人知道我將如何返回值x
, y
, w
和h
嗎? 下面的代碼不起作用,但是是我要實現的示例
const selectorRect = (function() { let x = undefined; let y = undefined; let w = undefined; let h = undefined; return { x: x, y: y, w: w, h: h }; })(); console.log(selectorRect);
ES6允許您使用速記屬性值。
const selectorRect = () => {
let x = undefined;
let y = undefined;
let w = undefined;
let h = undefined;
return { x, y, w, h }
}
console.log(selectorRect())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.