<legend id='MVBza'><style id='MVBza'><dir id='MVBza'><q id='MVBza'></q></dir></style></legend>

  1. <i id='MVBza'><tr id='MVBza'><dt id='MVBza'><q id='MVBza'><span id='MVBza'><b id='MVBza'><form id='MVBza'><ins id='MVBza'></ins><ul id='MVBza'></ul><sub id='MVBza'></sub></form><legend id='MVBza'></legend><bdo id='MVBza'><pre id='MVBza'><center id='MVBza'></center></pre></bdo></b><th id='MVBza'></th></span></q></dt></tr></i><div id='MVBza'><tfoot id='MVBza'></tfoot><dl id='MVBza'><fieldset id='MVBza'></fieldset></dl></div>
    • <bdo id='MVBza'></bdo><ul id='MVBza'></ul>
  2. <small id='MVBza'></small><noframes id='MVBza'>

    1. <tfoot id='MVBza'></tfoot>
    2. 函数的 JavaScript 参数中的花括号

      时间:2023-10-21
        <legend id='WLmS0'><style id='WLmS0'><dir id='WLmS0'><q id='WLmS0'></q></dir></style></legend>

      1. <tfoot id='WLmS0'></tfoot>
          <bdo id='WLmS0'></bdo><ul id='WLmS0'></ul>
          <i id='WLmS0'><tr id='WLmS0'><dt id='WLmS0'><q id='WLmS0'><span id='WLmS0'><b id='WLmS0'><form id='WLmS0'><ins id='WLmS0'></ins><ul id='WLmS0'></ul><sub id='WLmS0'></sub></form><legend id='WLmS0'></legend><bdo id='WLmS0'><pre id='WLmS0'><center id='WLmS0'></center></pre></bdo></b><th id='WLmS0'></th></span></q></dt></tr></i><div id='WLmS0'><tfoot id='WLmS0'></tfoot><dl id='WLmS0'><fieldset id='WLmS0'></fieldset></dl></div>

            <tbody id='WLmS0'></tbody>

          <small id='WLmS0'></small><noframes id='WLmS0'>

              • 本文介绍了函数的 JavaScript 参数中的花括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                围绕 JavaScript 函数参数的花括号有什么作用?

                What do the curly braces surrounding JavaScript arguments for functions do?

                var port = chrome.extension.connect({name: "testing"});
                port.postMessage({found: (count != undefined)});
                

                推荐答案

                花括号表示一个对象字面量.这是一种发送数据键/值对的方式.

                The curly braces denote an object literal. It is a way of sending key/value pairs of data.

                所以这个:

                var obj = {name: "testing"};
                

                这样用来访问数据.

                obj.name; // gives you "testing"
                

                你可以给对象几个逗号分隔的键/值对,只要键是唯一的.

                You can give the object several comma separated key/value pairs, as long as the keys are unique.

                var obj = {name: "testing",
                           another: "some other value",
                           "a-key": "needed quotes because of the hyphen"
                          };
                

                您还可以使用方括号来访问对象的属性.

                You can also use square brackets to access the properties of the object.

                这在 "a-key" 的情况下是必需的.

                This would be required in the case of the "a-key".

                obj["a-key"] // gives you "needed quotes because of the hyphen"
                

                使用方括号,您可以使用存储在变量中的属性名称访问值.

                Using the square brackets, you can access a value using a property name stored in a variable.

                var some_variable = "name";
                
                obj[ some_variable ] // gives you "testing"
                

                这篇关于函数的 JavaScript 参数中的花括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:jQuery将更多参数传递给回调 下一篇:Javascript:参数数组是否已弃用?

                相关文章

                <i id='Er8wR'><tr id='Er8wR'><dt id='Er8wR'><q id='Er8wR'><span id='Er8wR'><b id='Er8wR'><form id='Er8wR'><ins id='Er8wR'></ins><ul id='Er8wR'></ul><sub id='Er8wR'></sub></form><legend id='Er8wR'></legend><bdo id='Er8wR'><pre id='Er8wR'><center id='Er8wR'></center></pre></bdo></b><th id='Er8wR'></th></span></q></dt></tr></i><div id='Er8wR'><tfoot id='Er8wR'></tfoot><dl id='Er8wR'><fieldset id='Er8wR'></fieldset></dl></div>
                <tfoot id='Er8wR'></tfoot>

                1. <legend id='Er8wR'><style id='Er8wR'><dir id='Er8wR'><q id='Er8wR'></q></dir></style></legend>
                  • <bdo id='Er8wR'></bdo><ul id='Er8wR'></ul>

                  <small id='Er8wR'></small><noframes id='Er8wR'>