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 ...
随机推荐
- UserControl和CustomControl两者区别
UserControl 将多个WPF控件(例如:TextBox,TextBlock,Button)进行组合成一个可复用的控件组: 由XAML和Code Behind代码组成: 不支持样式/模板重写: ...
- CAP理论解读
经历过技术面试的小伙伴想必对这个两个概念已经再熟悉不过了! 我当年参加面试的时候,不夸张地说,只要问到分布式相关的内容,面试官几乎是必定会问这两个分布式相关的理论. 并且,这两个理论也可以说是小伙伴们 ...
- 剖析 CopyOnWriteArrayList
原文链接:https://www.changxuan.top/?p=1252 CopyOnWriteArrayList 是 JUC 中唯一一个支持并发的 List. CopyOnWriteArrayL ...
- 跟着Vimtutor学习Vim
跟着Vimtutor学习Vim Lesson 1 1.1 移动光标 在Vim中移动光标,分别使用h.j.k.l键代表左.下.上.右方向. 1.2 退出VIM :q! <ENTER> 退出V ...
- python中如何添加模块导入路径?
python中自定义模块导入路径的方式主要有以下3种: (1)使用sys.path.append() 随着程序执行,会动态地添加模块导入的路径,但是程序执行结束后就会立即失效(临时性的) import ...
- cloudera manager server迁移
一.迁移背景 服务器出了问题,导致整个cm server界面呈现出不可用的状态,也就是获取不到各个大数据组件以及主机相关的状态的信息,整个cm server的前端界面处于瘫痪的状态,不可用,刚开始怀疑 ...
- CF-559C Gerald and Giant Chess(计数DP)
给定一个 \(H*W\)的棋盘,棋盘上只有\(N\) 个格子是黑色的,其他格子都是白色的. 在棋盘左上角有一个卒,每一步可以向右或者向下移动一格,并且不能移动到黑色格子中.求这个卒从左上角移动到右下角 ...
- HDU - 2825 Wireless Password (AC自动机+状压DP)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2825 题意:给一些字符串,构造出长度为n的字符串,它至少包含k个所给字符串,求能构造出的个数. 题解: ...
- int和longlong的范围
unsigned int 0-4294967295 (10位数,4e9) int -2147483648-2147483647 (10位 ...
- 哈希算法解决:HDU1686 && POJ2774 && POJ3261
HDU1686 题意: 找A串在B串中的出现次数(可重叠),可用KMP做,这里只提供哈希算法做的方法 题解: 先得到A串的hash值,然后在B中枚举起点,长度为lena的子串,检验hash值是否相同就 ...