Home > front end >  Give a person (the person) by method (setPerson) to add attributes (name: 'xm, age: 18, sex:�
Give a person (the person) by method (setPerson) to add attributes (name: 'xm, age: 18, sex:�

Time:10-31



<meta charset="utf-8"/& gt;
Method is called & lt;/title> <br/></head> <br/><body> <br/><The script type="text/javascript" & gt; <br/>Complete the task//here <br/>Var person={<br/>SetPerson: function (property, value) {<br/>Enclosing the property=peoperty; <br/>this.value=https://bbs.csdn.net/topics/value; <br/>Return (property: value) <br/>}, <br/>} <br/>The console. The log (person. SetPerson (name, 'xm));//not hand in the parameter <br/></script> <br/></body> <br/></html> <br/><strong> how to call a function to add attributes </strong><p class="article - content rp"> CodePudding user response: </p><pre> var person={<br/>SetPerson: function (property, value) {<br/>Enclosing the property=property; <br/>This value=https://bbs.csdn.net/topics/value; <br/>}, <br/>}; <br/>Person. SetPerson (" name ", "xm"); <br/>The console. The log (person, property, person. Value); </pre><p class="article - content rp"> CodePudding user response: </p>Complete the task//here <br/>Var person={<br/>SetPerson: function (property, value) {<br/><span style="color: # FF0000;"> this [property]=value; </span> <br/>Return this <br/>}, <br/>} <br/>The console. The log (person. SetPerson (<span style="color: # FF0000;"> </span> 'name', 'xm));//not hand in the parameter<p class="article - content rp"> CodePudding user response: </p>. Just before you also see a problem <br/>The result? <br/><pre> <br/>Var person={<br/>SetPerson: function (property: any, value: any) {<br/>This [property]=value; <br/>Return ({property: value}) <br/>} <br/>} <br/>The console. The log (person. SetPerson (name, 'xm)); </pre> <br/><br/>If it is, well, actually I suggest you first look at the base will be better, I said "look at base," refers to "do" by watching them, even if it is according to the example of see to change, and then the relevant knowledge, can seek to understand more about baidu, otherwise, you'll be too tired </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/frontend/75074.html" target="_blank" style="color:#999">https//www.codepudding.com/frontend/75074.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/frontend/75073.html'>Why the output is the object on the page</a></div> <div class="detail-arr-right">Next:<a href='/frontend/75075.html'>Can want to consult the problem in JavaScript</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=JavaScript' target='_blank'>JavaScript</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>