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 ...
随机推荐
- 就是通过事件方法,在window.loaction.href里追加了参数字符串
参考博文:https://www.kancloud.cn/digest/yvettelau/137669
- 在不同情况下connect失败和ping不通的数据分析
- 慕课网金职位 Python工程师 百度网盘下载
百度网盘链接:https://pan.baidu.com/s/1xshLRO3ru0LAsQQ0pE67Qg 提取码:bh9f 如果失效加我微信:610060008[视频不加密,资料代码齐全,超清一手 ...
- LOJ10199轻拍牛头
题目描述 原题来自:USACO 2008 Dec. Silver 今天是 Bessie 的生日,并且现在是聚会的游戏时间.Bessie 让编号为 1~N 的 N 头奶牛围成一个圈坐(所以除了最后一头牛 ...
- SpringMVC听课笔记(十一:国际化)
1. 关于国际化 -- 在页面上根据浏览器的语言设置情况对文本(不是内容),时间,数值进行本地化处理 使用JSTL的fmt标签 -- 可以在bean中获取国际化资源文件 Locale对应的消息 在be ...
- 使用Docker部署监控系统,Prometheus,Grafana,监控服务器信息及Mysql
使用Docker部署监控系统,Prometheus,Grafana,监控服务器信息及Mysql 一.docker部署prometheus监控系统 1.1 配置安装环境 1.1.1 安装promethe ...
- UML——宏观总结
今天果断开始UML的学习,要不就要被12期赶超了.努力学习的效率 一.宏观导图把控 导图概要说明:RUP这块儿的内容相当于软件工程已经学过了,只不过这里换了个名词而已.面向对象,已经不再陌生,vb中早 ...
- HTML字体
字体相关的样式 color 用来设置字体颜色 font-size 字体的大小 和font-size相关的单位 em 相当于当前元素的一个font-size rem 相当于根元素的一个font-size ...
- Codeforces Round #659 (Div. 2) A. Common Prefixes
题目链接:https://codeforces.com/contest/1384/problem/A 题意 构造 $n+1$ 个字符串,使得 $n$ 对相邻字符串的相同前缀长度对应于数组 $a$ . ...
- 2020牛客暑期多校训练营(第八场) Kabaleo Lite
传送门:Kabaleo Lite 题意 有n道菜,1≤n≤105,a[i]是每道菜可以赚的钱,−109≤ ai ≤109,b[i]是这道菜的个数,1≤bi≤105,你每次只能选从1开始连续的菜,然后问 ...