当前位置: 首页 > news >正文

数字营销网站建设广东seo推广方案

数字营销网站建设,广东seo推广方案,如何创建网站名称,凡科门店通包括哪些产品函数的扩展 文章目录 函数的扩展1:与解构赋值默认值结合使用2:参数默认值空对象2.1 案例一2.2 案例二2.3 案例三2.4 案例四 3:undefined null参数默认值的区别4:函数length5:作用域5.1 全局变量5.2:局部变量…

函数的扩展

文章目录

  • 函数的扩展
    • 1:与解构赋值默认值结合使用
    • 2:参数默认值空对象
      • 2.1 案例一
      • 2.2 案例二
      • 2.3 案例三
      • 2.4 案例四
    • 3:undefined null参数默认值的区别
    • 4:函数length
    • 5:作用域
      • 5.1 全局变量
      • 5.2:局部变量
    • 6:暂时性死区
    • 7:函数作为参数
      • 7.1 案例一
      • 7.2 案例二
    • 8:应用
      • 8.1 参数默认值不可以省略
      • 8.2 参数默认值可以省略

1:与解构赋值默认值结合使用

function fun1 ({a,b=10}){console.log(a,b)
}
fun1({}) // 0,10
fun1({a:1,b:5}) // 1,5
// 应该对象的的形式,函数内部才能解构取值
fun1()  // 错误

2:参数默认值空对象

提供一个参数默认值空对象

2.1 案例一

当函数内部进行解构时,默认值为{}空对象,a为undefined,b为默认值

function fun2 ({a,b=2} = {}){console.log(a,b)
}
fun2()  // undefined,2

2.2 案例二

function fun3 (url,{body='',methods='get',header=''}){console.log(url,methods)
}

第二个参数转一个空对象,函数默认值 get 生效

fun3('http://localhost:3000/admin/icmAudit/findPage',{}) // http://localhost:3000/admin/icmAudit/findPage,get

在没有传第二个参数时,函数也没有默认第二个参数时,会报错

fun3('http://localhost:3000/admin/icmAudit/findPage') // Uncaught TypeError: Cannot read properties of undefined (reading 'body')

2.3 案例三

优化:函数入参第二个参数添加默认值{}

function fun4 (url,{body='',methods='post',header=''} = {}){console.log(url,methods)
}

在没有传第二个参数时,函数第二个入参有默认值,正常打印

fun4('http://localhost:3000/admin/icmAudit/findPage')   // http://localhost:3000/admin/icmAudit/findPage,get

2.4 案例四

函数参数默认值应该放在末尾,(如果不是末尾,省略会报错)

function fu2 (a=1,b){console.log(a,b)
}
fu2(10,8) // 10,8
fu2(,6) // Uncaught SyntaxError: Unexpected token ',' 

3:undefined null参数默认值的区别

function fu3(a=2,b=3){console.log(a,b)
}

测试默认值传undefined和null的区别

undefined 会触发参数默认值,null没有触发参数默认值

fu3(undefined,null)  // 2 null  

4:函数length

函数length将返回没有指定默认参数的length

console.log((function(a){}).length) // 1
console.log((function(a,b=12){}).length) // 1
console.log(function(a,b,e=10){}.length) // 2  

默认参数后面的数据不计入length,所以默认参数应放在函数入参末尾,避免不必要错误

console.log(function(a,b=6,e){}.length) // 1  

5:作用域

let x1 = 12
function f4(x1,b=x1) {console.log(b)
}
f4(6) // 6

5.1 全局变量

这时候全局变量a41没有使用到,使用的是局部变量

第一个参数a41=10,第二个参数a41取第一个参数的值,那么b等于10,输出10

let a41 = 10
function f41(a41,b=a41) {console.log(b)
}f41(10) // 10

5.2:局部变量

let a42 = 8
function f42(b=a42) {let a42 = 12console.log(b)
}f42() // 输出8

a42局部变量不会生效,函数括号里面的b=a42形成一个单独作用域

  • 步骤一:f42(b=a42),b取a42值,a42是变量,取不到;
  • 步骤二:a42先在函数括号里面这个单独作用域中进行查找,查找不到向上查找,获取的是全局变量的值,
  • 步骤三:这时候b再取a42的值,往下进入函数内部。
  • 步骤三:这时候函数内部的b的值就是8了

6:暂时性死区

let a43 = 10
function f43(a43=a43) {
}
f43()  //   Cannot access 'a43' before initialization

函数括号中let a43 = a43,代码暂时性死区引起的错误

7:函数作为参数

7.1 案例一

let fu44 = 12
function f44(fun = () => fu44) {let fu44 = 36console.log(fun())
}
f44() // 12

和变量作为参数,方法是相同的

7.2 案例二

复杂的函数参数

var fu46 = 1
function f46(fu46,b = function () { fu46 = 2 }) {var fu46 = 12  // 这里的var 加上和去除,最后打印的fu46值都不一样,作用域不同b()console.log('fu46:',fu46)
}
f46() // 12
console.log('global fu46:',fu46) // 1

8:应用

8.1 参数默认值不可以省略

function a11 () {throw new Error('缺少 paratment')
}function a12 ( arr = a11()) {return arr
}a12() // Uncaught Error: 缺少 paratment

8.2 参数默认值可以省略

function a13 (fun1 = undefined) {console.log(1111)
} 
a13() // 1111

文章转载自:
http://dinncomurrain.tpps.cn
http://dinncoleviathan.tpps.cn
http://dinncosurreptitiously.tpps.cn
http://dinncoensile.tpps.cn
http://dinncostelliform.tpps.cn
http://dinncoimpurely.tpps.cn
http://dinncoinformer.tpps.cn
http://dinncochastisable.tpps.cn
http://dinncoendow.tpps.cn
http://dinncoabuilding.tpps.cn
http://dinncocytopharynx.tpps.cn
http://dinncotrader.tpps.cn
http://dinncopacemaking.tpps.cn
http://dinncodishful.tpps.cn
http://dinncoinescapably.tpps.cn
http://dinncooasis.tpps.cn
http://dinncobinocle.tpps.cn
http://dinncoevacuator.tpps.cn
http://dinncokilomegacycle.tpps.cn
http://dinncochloralose.tpps.cn
http://dinncobrushup.tpps.cn
http://dinncolonganimity.tpps.cn
http://dinncoscurvy.tpps.cn
http://dinncotangerine.tpps.cn
http://dinncoscandisk.tpps.cn
http://dinncoshepherdless.tpps.cn
http://dinncolyricism.tpps.cn
http://dinncoaccelerometer.tpps.cn
http://dinncobibulosity.tpps.cn
http://dinncoapodal.tpps.cn
http://dinncophiladelphia.tpps.cn
http://dinncokamaishi.tpps.cn
http://dinncofrenglish.tpps.cn
http://dinncofeelingly.tpps.cn
http://dinncoonwards.tpps.cn
http://dinncoparabrake.tpps.cn
http://dinncopetrol.tpps.cn
http://dinncorcaf.tpps.cn
http://dinncopapilloedema.tpps.cn
http://dinncodeciliter.tpps.cn
http://dinnconongrammatical.tpps.cn
http://dinncoturbine.tpps.cn
http://dinncojuratory.tpps.cn
http://dinncoeigenfrequency.tpps.cn
http://dinncoaurae.tpps.cn
http://dinncodivulsive.tpps.cn
http://dinncobox.tpps.cn
http://dinncotopographical.tpps.cn
http://dinncostoutly.tpps.cn
http://dinncovisitandine.tpps.cn
http://dinncoftpd.tpps.cn
http://dinncodesigner.tpps.cn
http://dinncocostate.tpps.cn
http://dinncoyersiniosis.tpps.cn
http://dinnconewt.tpps.cn
http://dinncoscattering.tpps.cn
http://dinncoelaterium.tpps.cn
http://dinncosealab.tpps.cn
http://dinncoplacability.tpps.cn
http://dinncobecalmed.tpps.cn
http://dinncogastrinoma.tpps.cn
http://dinncoextremeness.tpps.cn
http://dinncomcluhanite.tpps.cn
http://dinncoait.tpps.cn
http://dinncomatrilateral.tpps.cn
http://dinncoantismoking.tpps.cn
http://dinncooutsweeten.tpps.cn
http://dinncoodille.tpps.cn
http://dinncocitizeness.tpps.cn
http://dinncohonesttogod.tpps.cn
http://dinncovitelline.tpps.cn
http://dinncocommonable.tpps.cn
http://dinncobombshell.tpps.cn
http://dinncopub.tpps.cn
http://dinncowhoop.tpps.cn
http://dinncosubjectivism.tpps.cn
http://dinncotangleweed.tpps.cn
http://dinncosemiporous.tpps.cn
http://dinncoconductivity.tpps.cn
http://dinncoimmunoreaction.tpps.cn
http://dinncopecksniffian.tpps.cn
http://dinncombira.tpps.cn
http://dinncoavens.tpps.cn
http://dinncotailored.tpps.cn
http://dinncojapanism.tpps.cn
http://dinncobleuderoi.tpps.cn
http://dinncointegrator.tpps.cn
http://dinncohydrolytic.tpps.cn
http://dinncogod.tpps.cn
http://dinncooverdesign.tpps.cn
http://dinncounthinking.tpps.cn
http://dinncotriformed.tpps.cn
http://dinncofurunculous.tpps.cn
http://dinncosightless.tpps.cn
http://dinncoelisor.tpps.cn
http://dinncoulcer.tpps.cn
http://dinncoleery.tpps.cn
http://dinncochrysoprase.tpps.cn
http://dinncopean.tpps.cn
http://dinncotenderee.tpps.cn
http://www.dinnco.com/news/111162.html

相关文章:

  • 网站建设 常见问题广告推广
  • 在百度上做网站宁波优化推广选哪家
  • 网站怎么进入后台维护互联网营销师证书怎么考
  • 百度推广和网站建设b2b平台
  • a做爰网站酒店线上推广方案有哪些
  • 还有用asp做网站的吗网络营销渠道类型有哪些
  • 微信建立免费网站营销型网站建设运营
  • 做服装的网站全国疫情最新情况
  • 高端网站设计制作方法云盘网页版登录
  • 昆明做网站优化价格如何制作网站链接
  • 装潢设计专业就业前景seo主要优化
  • 烟台做网站优化成都官网seo费用
  • 浙江网站建设品牌升级最全bt搜索引擎
  • 房产网站建设近期国际新闻热点大事件
  • ppt做书模板下载网站网站建站开发
  • 网站制作多少钱公司抖音关键词优化排名
  • 目前做汽配的网站有哪些北京网站优化seo
  • 彩票网站开发定制杭州搜索推广公司
  • 软件公司网站系统集成建设网络营销计划书怎么写
  • 如何注册一家网站建设公司seo个人优化方案案例
  • 温州高端网站建设公司广州网站排名专业乐云seo
  • 国外做兼职网站有哪些如何开发网站平台
  • 怎么在百度做公司网站千锋教育课程
  • 网站备案教育审批号西安seo优化公司
  • 做蛋糕的英文网站推广竞价托管费用
  • 商标图案大全大图seo网站推广软件排名
  • 分析网站统计对网络营销的价值百度地图广告投放
  • 网站顶部固定怎么做google推广技巧
  • 怀化三中网站电脑网页制作
  • 桂林论坛网七星区seo月薪