Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从节点模块的函数开头删除包名_Javascript_Node.js_Node Modules - Fatal编程技术网

Javascript 如何从节点模块的函数开头删除包名

Javascript 如何从节点模块的函数开头删除包名,javascript,node.js,node-modules,Javascript,Node.js,Node Modules,因此,我有一个节点模块,但我想知道如果函数不使用this,如何将somethingElse()转换为somethingElse(): const somethingElse = something.somethingElse; or const { somethingElse } = require('something'); or import { somethingElse } from 'something'; 如果它确实需要此,则需要使用绑定,以便此设置正确: const some

因此,我有一个节点模块,但我想知道如果函数不使用
this
,如何将
somethingElse()
转换为
somethingElse()

const somethingElse = something.somethingElse;
or 
const { somethingElse } = require('something');
or 
import { somethingElse } from 'something';
如果它确实需要
,则需要使用
绑定
,以便
设置正确:

const somethingElse = something.somethingElse.bind(something);

有趣的是,你可能不知道它是否需要
这个
,除非你尝试了它,它抛出了一个错误

如果函数不使用此

const somethingElse = something.somethingElse;
or 
const { somethingElse } = require('something');
or 
import { somethingElse } from 'something';
如果它确实需要
,则需要使用
绑定
,以便
设置正确:

const somethingElse = something.somethingElse.bind(something);
有趣的是,你可能不知道它是否需要
这个
,除非你尝试了它,它抛出了一个错误