x:y语法在JavaScript中是什么意思?

交换

我正在学习有关区块链的课程,其中包含以下代码。“ index:this.chain.length + 1”是什么意思?索引是对象newBlock中的变量吗?还是键值对?如果它是一个变量,为什么我们不简单地使用index = this.chain.length + 1?另外,对象newBlock的类型是什么?

function Blockchain()
{
  this.chain=[];
  this.newTranscations=[];
}

Blockchain.prototype.createNeBlock = function(nonce,previousBlockHash,hash)
{
  const newBlock ={
    index:this.chain.length+1,
    timestamp:Date.now(),
    // all of the transactions in this block will be the transactions that waiting to be put in a block
    transactions:this.newTranscations,
    // nonce is hust a number giving proof of the transaction
    nonce:nonce,
    hash:hash,
    previousBlockHash: previousBlockHash
  }
  // As we move all the pending transactions to the new block, we clear this array
  this.newTranscations=[];
  this.chain.push(newBlock);
  return newBlock; 
}
Blanknamefornow
var Box = {
"playdoh":{"playdoh":["none", "some", "none", "none", "some"]}
};

一盒又一盒的Playdoh,您正在研究Objects / Arrays / Maps。

要将以上内容称为“

console.log(Box["playdoh"]["playdoh"][0]);
= none

console.log(Box["playdoh"]["playdoh"][4]);
= some

console.log(Box["playdoh"]["playdoh"][5]);
= null (undefined)

是相同的

console.log(Box.playdoh.playdoh[0]);
= none

console.log(Box.playdoh.playdoh[4]);
= some

console.log(Box.playdoh.playdoh[5]);
= null (undefined)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

(JSX)是React中JavaScript的语法扩展是什么意思

来自分类Dev

javascript:Function语法是什么意思?

来自分类Dev

以下javascript语法是什么意思?

来自分类Dev

以下javascript语法是什么意思?

来自分类Dev

这个语法是什么意思 JAVASCRIPT

来自分类Dev

::在Ruby语法中是什么意思?

来自分类Dev

if语法中的','是什么意思?

来自分类Dev

Lombok中的语法@@()是什么意思?

来自分类Dev

if语法中的','是什么意思?

来自分类Dev

myFunction(x:y:xs)在Haskell中是什么意思

来自分类Dev

bash中的“ x [y] =([z] = w)”是什么意思?

来自分类Dev

fsck输出中的“ clean,x / y”是什么意思?

来自分类Dev

myFunction(x:y:xs)在Haskell中是什么意思

来自分类Dev

ppa:x / y是什么意思

来自分类Dev

*[ ... ] 语法是什么意思?

来自分类Dev

(x:) 在haskell中是什么意思

来自分类Dev

||是什么意思 在JavaScript中?

来自分类Dev

JavaScript中的“-$ 1”是什么意思?

来自分类Dev

+是什么意思!在JavaScript中?

来自分类Dev

“ object || {}”在javascript中是什么意思?

来自分类Dev

javascript中的“!〜”是什么意思

来自分类Dev

javascript中的obj ['']是什么意思?

来自分类Dev

$ .expr [':']在javascript中是什么意思

来自分类Dev

$(function(){})在javascript中是什么意思

来自分类Dev

|| {}在javascript中是什么意思?

来自分类Dev

JavaScript中“ =>”是什么意思?

来自分类Dev

在Javascript中,ƒ是什么意思?

来自分类Dev

[]。$在JavaScript中是什么意思?

来自分类Dev

###在javascript中是什么意思