先看代码:

function example (){

  var index=1;

  return {//像这种加个大括号的就是返回一个对象了,而不仅仅是一个值

    index,

    net:function(){

      return { value:++index,name:'wang'}

          }

    }

}

var runExample=example();

runExample;//z这是example函数运行后的结果,返回的是一个对象,包含index属性和net函数。

runExample.index;//得到的是runExample函数运行后里边对象的index属性值。

net;//返回的是一个函数

net();//这个是net里边运行后得到的结果,返回的是一个对象,具体为:object{value:2,name:'wang'}

 

相关文章:

  • 2022-12-23
  • 2021-09-05
  • 2021-04-01
  • 2021-12-30
  • 2022-02-19
  • 2021-08-11
  • 2022-12-23
  • 2021-10-14
猜你喜欢
  • 2021-12-03
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
  • 2021-10-08
  • 2022-12-23
相关资源
相似解决方案