How to use constants as Object keys
まだ誰も着手していません。
評価
- 難易度
- 1/5
- 見積もり時間
- 1時間未満
- 初心者へのやさしさ
- 42/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
調査の方向性
参照されている動画セグメント、提供された p5.js の例、および computed property names に関する MDN のリファレンスを確認してください。関連するプロジェクトのガイダンスを更新し、角括弧が定数の数値をオブジェクトのキーとして使用することを説明したうえで、修正後の例が示されている出力と一致することを検証してください。
索引モデルが issue の本文から書いたものです。
説明
At 22:24 in the video Dan tries to use his constants as the keys in the object but it doesn't work for him. This is because he did it wrong.
when he did it you ended up with an object that had the strings "UP", "DOWN", etc as the keys but you wanted it to be the numbers that those constants represented. The way that you do that is to put the variables in square brackets. For example.
const UP = 0;
const DOWN = 1;
const LEFT = 2;
const RIGHT = 3;
const object1 = {
UP: [],
DOWN: [],
LEFT: [],
RIGHT: []
}
const object2 = {
[UP]: [],
[DOWN]: [],
[LEFT]: [],
[RIGHT]: []
}
console.log(object1) => // {UP: Array(0), DOWN: Array(0), LEFT: Array(0), RIGHT: Array(0)}
console.log(object2) => // {0: Array(0), 1: Array(0), 2: Array(0), 3: Array(0)}
}
and here's an interactive example https://editor.p5js.org/D_Snyder/sketches/r7rHl0QuA
The term for this is Computed Property Names and more details can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#computed_property_names
- 主要言語
- JavaScript
- スター
- 219
- フォーク
- 64
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CodingTrain/Wave-Function-Collapse のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
CodingTrain/Wave-Function-Collapse#41 · リアクション 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
CodingTrain/Wave-Function-Collapse#38 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
CodingTrain/Wave-Function-Collapse#37 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
-
Preload more data オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
CodingTrain/Wave-Function-Collapse#26 · コメント 1 件 ·
CodingTrain/Wave-Function-Collapse の issue をすべて見る
似ている issue
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
georgestephanis/p2026#40 ·
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Margaret-Petersen/food-delivery-app-clone-react-native#1981 ·