auto skip function args
auto skip function args
https://repl.it/@xgqfrms/auto-skip-function-args
"use strict";
/**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
* @created 2019-09-28
* @modified
*
* @description auto skip function args that not actually used
* @description Automatically skip parameters that are not actually used by the function
* @description 自动跳过函数实际上没有使用的参数
* @augments
* @example
* @link
*
*/
let log = console.log;
// this OK
const autoSkipArgs = (fn, skipArgsNumber, args) => {
fn.apply(this, Array(skipArgsNumber).concat([args]));
}
// function autoSkipArgs(fn, skipArgsNumber, args) {
// fn.apply(this, Array(skipArgsNumber).concat([args]));
// }
export default autoSkipArgs;
export {
autoSkipArgs,
};
// testing
/*
let log = console.log;
const func = (arg1 = ``, arg2 = {}) => {
log(`arg1`, arg1);
log(`arg2`, arg2);
};
let obj = {
key: 1,
value: "A",
};
autoSkipArgs(func, 1, obj);
// arg1
// arg2 { key: 1, value: 'A' }
*/

array & empty bug


Uint8Array
new Uint8Array(2).map(i => "");
// Uint8Array(2) [0, 0]
new Uint8Array(2);
// Uint8Array(2) [0, 0]
[...new Uint8Array(2).map(i => "")]
// (2) [0, 0]
[...new Uint8Array(2)].map(i => "");
// (2) ["", ""]

site: www.stackoverflow.com js function ignore first arguments
https://stackoverflow.com/questions/32518615/skip-arguments-in-a-javascript-function

https://stackoverflow.com/questions/25642690/javascript-skip-arguments-in-function-call
https://stackoverflow.com/questions/38224231/how-to-remove-the-first-argument-of-function
shit antd & table col render
https://ant.design/components/table-cn/#Column
render(text, record, index)

https://codesandbox.io/s/antd-table-auto-skip-args-j1vu2

import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import "./index.css";
import { Table, Badge, Menu, Dropdown, Icon } from "antd";
const menu = (
<Menu>
<Menu.Item>Action 1</Menu.Item>
<Menu.Item>Action 2</Menu.Item>
</Menu>
);
let log = console.log;
function NestedTable() {
const columns = [
{ title: "Name", dataIndex: "name", key: "name" },
{ title: "Platform", dataIndex: "platform", key: "platform" },
{ title: "Version", dataIndex: "version", key: "version" },
{ title: "Upgraded", dataIndex: "upgradeNum", key: "upgradeNum" },
{
title: "Creator",
dataIndex: "creator",
key: "creator",
// render: (undefined, undefined, index) => {
// render: ("", "", index) => {
// render: ("x", "x", index) => {
render: (a, b, index) => {
log(`index`, index);
return <span>auto sikp args</span>;
}
},
{
title: "Date",
dataIndex: "createdAt",
key: "createdAt",
render: (text, record, index) => {
log(`text`, text, index);
// log(`record`, record);
return <span>{text}</span>;
}
},
{
title: "Action",
key: "operation",
render: (record, index) => {
// log(`record`, record, index);
return <a>Publish</a>;
}
}
];
const data = [];
for (let i = 0; i < 3; ++i) {
data.push({
key: i,
name: "Screem",
platform: "iOS",
version: "10.3.4.5654",
upgradeNum: 500,
creator: "Jack",
createdAt: "2014-12-24 23:12:00"
});
}
return (
<Table
className="components-table-demo-nested"
columns={columns}
dataSource={data}
/>
);
}
ReactDOM.render(<NestedTable />, document.getElementById("container"));
anonymous function args bug ???
(...[...new Uint8Array(2)].map(i => ""), 123) => {
console.log(arguments[0]);
};
// Uncaught SyntaxError: Unexpected token '...'
copy(...[...new Uint8Array(2)].map(i => ""));
// undefined

arrow function & arguments bug

function abc(arg1, arg2) {
console.log(arguments[0]);
}
abc(...[...new Uint8Array(2)].map(i => ""), 123);
const f = (arg1, arg2) => {
console.log(arguments[0]);
};
f(...[...new Uint8Array(2)].map(i => ""), 123);
// VM769:2 Uncaught ReferenceError: arguments is not defined
auto skip function args的更多相关文章
- C++ 11 Lambda表达式、auto、function、bind、final、override
接触了cocos2dx 3.0,就必须得看C++ 11了.有分享过帖子:[转帖]漫话C++0x(四) —- function, bind和lambda.其实最后的Lambda没太怎么看懂. 看不懂没关 ...
- 搞懂function(*args,**kwargs)
给出一个例子: def foo(*args,**kwargs): print 'args=',args print 'kwargs=',kwargs print '------------------ ...
- 《理解 ES6》阅读整理:函数(Functions)(三)Function Constructor & Spread Operator
增强的Function构造函数(Increased Capabilities of the Function Constructor) 在Javascript中Function构造函数可以让你创建一个 ...
- ES6新特性:Function函数扩展, 扩展到看不懂
本文所有Demo的运行环境为nodeJS, 参考:让nodeJS支持ES6的词法----babel的安装和使用 : 函数的默认值: 如果有参数 ,那就用参数, 如果没有参数, 那就用默认的参数: aj ...
- KoaHub平台基于Node.js开发的Koa的skip插件代码详情
koahub-skip koahub skip middleware koahub skip Conditionally skip a middleware when a condition is m ...
- python 中的 args,*args,**kwargs的区别
一.*args的使用方法 *args 用来将参数打包成tuple给函数体调用 例子一:def function(*args): print(args, type(args))function ...
- js的一些function
/** * * 根据秒数返回 一个日期范围 * timerFilter(10) */ function timerFilter(n) { let days = 31; // 一月多少天 const o ...
- Mordern Effective C++ --auto
5. 优先使用auto而非显示类型声明 在C++之中,使用auto关键字声明类型可以将程序员从输入繁琐的类型中解放出来,编译器会自动推导出变量的实际类型. template<typename I ...
- [JS] ECMAScript 6 - String, Number, Function : compare with c#
字符串的扩展 正则的扩展 数值的扩展 函数的扩展 字符串的扩展 js 字符的 Unicode 表示法 codePointAt() String.fromCodePoint() 字符串的遍历器接口 at ...
随机推荐
- 济南学习D3T1__线性筛和阶乘质因数分解
[问题描述] 从1− N中找一些数乘起来使得答案是一个完全平方数,求这个完全平方数最大可能是多少. [输入格式] 第一行一个数字N. [输出格式] 一行,一个整数代表答案对100000007取模之后的 ...
- ESRI,空间数据处理,WKT,GeoJson
ESRI,空间数据处理,WKT,GeoJson 一.WKT 二.GeoJson 三.WKT转GeoJson 四.GeoJson 转 WKT 一.WKT WKT(well-known text)是一种文 ...
- Centos搭建Hive
Centos搭建Hive 一.Hive简介 二.安装Hive 2.1hive下载 2.2上传解压 2.3配置hive相关的环境变量 三.Mysql 3.1安装mysql connector 3.2 将 ...
- msf+cobaltstrike联动(二):把cs中的机器spwan给msf
前提:CS已经获取到session,可以进入图形化管理机器,现在需要使用msf进行进一步渗透,需要msf的metepreter. 开启msf msf设置监听 msf > use exploit/ ...
- k8s command & args
命令和参数说明: command.args两项实现覆盖Dockerfile中ENTRYPOINT的功能,具体的command命令代替ENTRYPOINT的命令行,args代表集体的参数. 如果comm ...
- 12.su 命令与sudo 服务
1.su 命令:解决切换用户身份的需求,使得当前用户在不退出登录的情况下,顺畅地切换到其他用户. 比如从root 管理员切换至普通用户: [root@Centos test]# id uid=0(r ...
- ogn1.MethodFailedException:Method "xxx" failed for object xxx
问题描述:初学ssh写了个小项目,访问界面出现以下错误 java. lang. NoSuchllethodError: org. hi bernate. SessionF actory. openSe ...
- MapReduce参数调优
原文链接:http://blog.javachen.com/2014/06/24/tuning-in-mapreduce/ 本文主要记录Hadoop 2.x版本中MapReduce参数调优,不涉及Ya ...
- 牛客挑战赛33 C 艾伦的立体机动装置(几何)
思路: 我们需要枚举展开多少条边 然后把上底面的点放到和下底面一个平面 然后算两点之间的距离 注意判断直线与线段是否有交点 #include <bits/stdc++.h> using n ...
- poj 3304 Segments(解题报告)
收获:举一反三:刷一道会一道 1:思路转化:(看的kuangbin的思路) 首先是在二维平面中:如果有很多线段能够映射到这个直线上并且至少重合于一点,充要条件: 是过这个点的此条直线的垂线与其他所有直 ...