博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
post 重复参数_参数名称重复
阅读量:2521 次
发布时间:2019-05-11

本文共 1196 字,大约阅读时间需要 3 分钟。

post 重复参数

Oftentimes we override or functions and, in many cases, there are arguments we don't care too much about. A common practice for those arguments is using _ for argument names -- it's a generally accepted and known practice for "this isn't important". I started thinking about multiple useless arguments and if you could use the same name for the sake of minification -- you can.

通常,我们会覆盖或函数,并且在许多情况下,有些参数我们不太在意。 这些参数的常见做法是使用_作为参数名称-这是“这并不重要”的普遍接受的已知做法。 我开始考虑多个无用的参数,如果为了简化而可以使用相同的名称,则可以。

So what happens when you use the same argument name more than once? An error? Uses the first value? The last value? Let's have a look:

那么当您多次使用相同的参数名称时会发生什么呢? 一个错误? 使用第一个值? 最后的价值? 我们来看一下:

function myFunc(_, _, _) {  console.log("_: ", _);}myFunc(1, 2, 3);// >> 3

The duplicated argument is given the value of the last provided argument. If, however, "use strict" is used, an error will be thrown.

为重复的参数提供最后提供的参数的值。 但是,如果"use strict" ,将引发错误。

For some reason I expected an error when using an argument name more than once. On the other end, you can change argument values so I shouldn't be surprised. Anyway, happy coding!

由于某种原因,我多次使用参数名称时会出现错误。 另一方面,您可以更改参数值,这样我就不会感到惊讶。 无论如何,祝您编程愉快!

翻译自:

post 重复参数

转载地址:http://ekvwd.baihongyu.com/

你可能感兴趣的文章
07-Java 中的IO操作
查看>>
uclibc,eglibc,glibc之间的区别和联系【转】
查看>>
Java魔法堂:找外援的利器——Runtime.exec详解
查看>>
mysql数据库存放路径
查看>>
TestNG(五)常用元素的操作
查看>>
解决 Visual Studio 点击添加引用无反应的问题
查看>>
通过镜像下载Android系统源码
查看>>
python字符串格式化 %操作符 {}操作符---总结
查看>>
windows 不能在 本地计算机 启动 Apache
查看>>
iOS开发报duplicate symbols for architecture x86_64错误的问题
查看>>
Chap-6 6.4.2 堆和栈
查看>>
【Java学习笔记之九】java二维数组及其多维数组的内存应用拓展延伸
查看>>
C# MySql 连接
查看>>
sk_buff Structure
查看>>
oracle的级联更新、删除
查看>>
多浏览器开发需要注意的问题之一
查看>>
Maven配置
查看>>
HttpServletRequest /HttpServletResponse
查看>>
SAM4E单片机之旅——24、使用DSP库求向量数量积
查看>>
从远程库克隆库
查看>>