012_call和apply区别
一、
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | function fn(a,b) { console.log(this); } fn.call(null,1,2); //call 为参数方式 fn.apply(null,[1,2]); //apply 为数组方式 /*输出=> Object [global] { DTRACE_NET_SERVER_CONNECTION: [Function], DTRACE_NET_STREAM_END: [Function], DTRACE_HTTP_SERVER_REQUEST: [Function], DTRACE_HTTP_SERVER_RESPONSE: [Function], DTRACE_HTTP_CLIENT_REQUEST: [Function], DTRACE_HTTP_CLIENT_RESPONSE: [Function], global: [Circular], process: process { title: '/usr/local/bin/node' , version: 'v10.3.0' , versions: { http_parser: '2.8.0' , node: '10.3.0' , v8: '6.6.346.32-node.9' , uv: '1.20.3' , zlib: '1.2.11' , ares: '1.14.0' , modules: '64' , nghttp2: '1.29.0' , napi: '3' , openssl: '1.1.0h' , icu: '61.1' , unicode: '10.0' , cldr: '33.0' , tz: '2018c' }, arch: 'x64' , platform: 'darwin' , release: { name: 'node' , sourceUrl: 'https://nodejs.org/download/release/v10.3.0/node-v10.3.0.tar.gz' , headersUrl: 'https://nodejs.org/download/release/v10.3.0/node-v10.3.0-headers.tar.gz' }, argv: [ '/usr/local/Cellar/node/10.3.0/bin/node' , '/Users/00arunalldata00/009_mystudy/010_everest/001_Everest4/20180628/201804/7.fs/11.fn.js' ], execArgv: [], env : { PATH: '/usr/local/opt/openssl/bin:/opt/vagrant/bin:/usr/local/sbin:/usr/local/opt/sqlite/bin:/usr/local/opt/openresty-openssl/bin:/usr/local/opt/icu4c/sbin:/usr/local/mysql/bin:/usr/local/opt/icu4c/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Applications/Wireshark.app/Contents/MacOS' , NVM_RC_VERSION: '' , FORCE_COLOR: 'true' , ELECTRON_NO_ATTACH_CONSOLE: 'true' , DEBUG_COLORS: 'true' , npm_config_color: 'always' , MOCHA_COLORS: '1' , VERSIONER_PYTHON_VERSION: '2.7' , LOGNAME: 'arunyang' , NVM_NODEJS_ORG_MIRROR: 'https://nodejs.org/dist' , XPC_SERVICE_NAME: 'com.jetbrains.WebStorm.77156' , PWD: '/Users/00arunalldata00/009_mystudy/010_everest/001_Everest4/20180628/201804/7.fs' , NVM_CD_FLAGS: '-q' , NVM_DIR: '/Users/arunyang/.nvm' , SHELL: '/bin/zsh' , PAGER: 'less' , LSCOLORS: 'Gxfxcxdxbxegedabagacad' , SECURITYSESSIONID: '186a8' , OLDPWD: '/Applications/WebStorm.app/Contents/bin' , VERSIONER_PYTHON_PREFER_32_BIT: 'no' , USER: 'arunyang' , ZSH: '/Users/arunyang/.oh-my-zsh' , TMPDIR: '/var/folders/wy/v0w9vkf52836x21w_jz2wzlh0000gn/T/' , SSH_AUTH_SOCK: '/private/tmp/com.apple.launchd.IKTjc3zbdP/Listeners' , XPC_FLAGS: '0x0' , NVM_IOJS_ORG_MIRROR: 'https://iojs.org/dist' , __CF_USER_TEXT_ENCODING: '0x1F5:0x0:0x0' , Apple_PubSub_Socket_Render: '/private/tmp/com.apple.launchd.huBMuc0K3M/Render' , LESS: '-R' , LC_CTYPE: '' , HOME: '/Users/arunyang' }, pid: 3023, features: { debug: false , uv: true , ipv6: true , tls_alpn: true , tls_sni: true , tls_ocsp: true , tls: true }, ppid: 2534, execPath: '/usr/local/Cellar/node/10.3.0/bin/node' , debugPort: 9229, _startProfilerIdleNotifier: [Function: _startProfilerIdleNotifier], _stopProfilerIdleNotifier: [Function: _stopProfilerIdleNotifier], _getActiveRequests: [Function: _getActiveRequests], _getActiveHandles: [Function: _getActiveHandles], reallyExit: [Function: reallyExit], abort: [Function: abort], chdir: [Function: chdir], cwd: [Function: cwd], umask : [Function: umask ], getuid: [Function: getuid], geteuid: [Function: geteuid], setuid: [Function: setuid], seteuid: [Function: seteuid], setgid: [Function: setgid], setegid: [Function: setegid], getgid: [Function: getgid], getegid: [Function: getegid], getgroups: [Function: getgroups], setgroups: [Function: setgroups], initgroups: [Function: initgroups], _kill: [Function: _kill], _debugProcess: [Function: _debugProcess], _debugEnd: [Function: _debugEnd], hrtime: [Function: hrtime], cpuUsage: [Function: cpuUsage], dlopen: [Function: dlopen], uptime: [Function: uptime], memoryUsage: [Function: memoryUsage], _rawDebug: [Function], moduleLoadList: [ 'Binding contextify' , 'NativeModule events' , 'NativeModule internal/async_hooks' , 'NativeModule internal/errors' , 'Binding uv' , 'Binding buffer' , 'Binding async_wrap' , 'Binding config' , 'Binding icu' , 'NativeModule util' , 'NativeModule internal/encoding' , 'NativeModule internal/util' , 'Binding constants' , 'Binding util' , 'NativeModule internal/util/types' , 'Internal Binding types' , 'NativeModule buffer' , 'NativeModule internal/buffer' , 'NativeModule internal/process' , 'NativeModule assert' , 'NativeModule internal/assert' , 'NativeModule fs' , 'NativeModule path' , 'NativeModule internal/constants' , 'Binding fs' , 'NativeModule stream' , 'NativeModule internal/streams/pipeline' , 'NativeModule internal/streams/end-of-stream' , 'NativeModule internal/streams/legacy' , 'NativeModule _stream_readable' , 'NativeModule internal/streams/buffer_list' , 'NativeModule internal/streams/destroy' , 'NativeModule internal/streams/state' , 'NativeModule _stream_writable' , 'NativeModule _stream_duplex' , 'NativeModule _stream_transform' , 'NativeModule _stream_passthrough' , 'Binding fs_event_wrap' , 'NativeModule internal/fs/utils' , 'NativeModule internal/url' , 'NativeModule internal/querystring' , 'Binding url' , 'NativeModule internal/process/warning' , 'NativeModule internal/process/next_tick' , 'NativeModule internal/process/promises' , 'NativeModule internal/fixed_queue' , 'NativeModule internal/process/stdio' , 'Binding performance' , 'Binding trace_events' , 'NativeModule internal/inspector_async_hook' , 'Binding inspector' , 'NativeModule timers' , 'Binding timer_wrap' , 'NativeModule internal/linkedlist' , 'NativeModule internal/timers' , 'NativeModule internal/modules/cjs/loader' , 'NativeModule vm' , 'NativeModule internal/modules/cjs/helpers' , 'NativeModule console' , 'Binding tty_wrap' , 'NativeModule net' , 'NativeModule internal/net' , 'Binding cares_wrap' , 'Binding stream_wrap' , 'Binding tcp_wrap' , 'Binding pipe_wrap' , 'NativeModule internal/stream_base_commons' ], binding: [Function: binding], _linkedBinding: [Function: _linkedBinding], _events: { newListener: [Function], removeListener: [Function], warning: [Function] }, _eventsCount: 3, _maxListeners: undefined, _fatalException: [Function], domain: null, _exiting: false , assert: [Function: deprecated], config: { target_defaults: [Object], variables: [Object] }, setUncaughtExceptionCaptureCallback: [Function], hasUncaughtExceptionCaptureCallback: [Function], emitWarning: [Function], nextTick: [Function: nextTick], _tickCallback: [Function: _tickCallback], stdout: [Getter], stderr: [Getter], stdin: [Getter], openStdin: [Function], exit : [Function], kill : [Function], argv0: '/usr/local/bin/node' , mainModule: Module { id : '.' , exports: {}, parent: null, filename: '/Users/00arunalldata00/009_mystudy/010_everest/001_Everest4/20180628/201804/7.fs/11.fn.js' , loaded: false , children: [], paths: [Array] } }, Buffer: { [Function: Buffer] poolSize: 8192, from: [Function: from], of: [Function: of], alloc: [Function: alloc], allocUnsafe: [Function: allocUnsafe], allocUnsafeSlow: [Function: allocUnsafeSlow], isBuffer: [Function: isBuffer], compare: [Function: compare], isEncoding: [Function: isEncoding], concat: [Function: concat], byteLength: [Function: byteLength], [Symbol(kIsEncodingSymbol)]: [Function: isEncoding] }, clearImmediate: [Function: clearImmediate], clearInterval: [Function: clearInterval], clearTimeout: [Function: clearTimeout], setImmediate: { [Function: setImmediate] [Symbol(util.promisify.custom)]: [Function] }, setInterval: [Function: setInterval], setTimeout: { [Function: setTimeout] [Symbol(util.promisify.custom)]: [Function] } } Object [global] { DTRACE_NET_SERVER_CONNECTION: [Function], DTRACE_NET_STREAM_END: [Function], DTRACE_HTTP_SERVER_REQUEST: [Function], DTRACE_HTTP_SERVER_RESPONSE: [Function], DTRACE_HTTP_CLIENT_REQUEST: [Function], DTRACE_HTTP_CLIENT_RESPONSE: [Function], global: [Circular], process: process { title: '/usr/local/bin/node' , version: 'v10.3.0' , versions: { http_parser: '2.8.0' , node: '10.3.0' , v8: '6.6.346.32-node.9' , uv: '1.20.3' , zlib: '1.2.11' , ares: '1.14.0' , modules: '64' , nghttp2: '1.29.0' , napi: '3' , openssl: '1.1.0h' , icu: '61.1' , unicode: '10.0' , cldr: '33.0' , tz: '2018c' }, arch: 'x64' , platform: 'darwin' , release: { name: 'node' , sourceUrl: 'https://nodejs.org/download/release/v10.3.0/node-v10.3.0.tar.gz' , headersUrl: 'https://nodejs.org/download/release/v10.3.0/node-v10.3.0-headers.tar.gz' }, argv: [ '/usr/local/Cellar/node/10.3.0/bin/node' , '/Users/00arunalldata00/009_mystudy/010_everest/001_Everest4/20180628/201804/7.fs/11.fn.js' ], execArgv: [], env : { PATH: '/usr/local/opt/openssl/bin:/opt/vagrant/bin:/usr/local/sbin:/usr/local/opt/sqlite/bin:/usr/local/opt/openresty-openssl/bin:/usr/local/opt/icu4c/sbin:/usr/local/mysql/bin:/usr/local/opt/icu4c/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Applications/Wireshark.app/Contents/MacOS' , NVM_RC_VERSION: '' , FORCE_COLOR: 'true' , ELECTRON_NO_ATTACH_CONSOLE: 'true' , DEBUG_COLORS: 'true' , npm_config_color: 'always' , MOCHA_COLORS: '1' , VERSIONER_PYTHON_VERSION: '2.7' , LOGNAME: 'arunyang' , NVM_NODEJS_ORG_MIRROR: 'https://nodejs.org/dist' , XPC_SERVICE_NAME: 'com.jetbrains.WebStorm.77156' , PWD: '/Users/00arunalldata00/009_mystudy/010_everest/001_Everest4/20180628/201804/7.fs' , NVM_CD_FLAGS: '-q' , NVM_DIR: '/Users/arunyang/.nvm' , SHELL: '/bin/zsh' , PAGER: 'less' , LSCOLORS: 'Gxfxcxdxbxegedabagacad' , SECURITYSESSIONID: '186a8' , OLDPWD: '/Applications/WebStorm.app/Contents/bin' , VERSIONER_PYTHON_PREFER_32_BIT: 'no' , USER: 'arunyang' , ZSH: '/Users/arunyang/.oh-my-zsh' , TMPDIR: '/var/folders/wy/v0w9vkf52836x21w_jz2wzlh0000gn/T/' , SSH_AUTH_SOCK: '/private/tmp/com.apple.launchd.IKTjc3zbdP/Listeners' , XPC_FLAGS: '0x0' , NVM_IOJS_ORG_MIRROR: 'https://iojs.org/dist' , __CF_USER_TEXT_ENCODING: '0x1F5:0x0:0x0' , Apple_PubSub_Socket_Render: '/private/tmp/com.apple.launchd.huBMuc0K3M/Render' , LESS: '-R' , LC_CTYPE: '' , HOME: '/Users/arunyang' }, pid: 3023, features: { debug: false , uv: true , ipv6: true , tls_alpn: true , tls_sni: true , tls_ocsp: true , tls: true }, ppid: 2534, execPath: '/usr/local/Cellar/node/10.3.0/bin/node' , debugPort: 9229, _startProfilerIdleNotifier: [Function: _startProfilerIdleNotifier], _stopProfilerIdleNotifier: [Function: _stopProfilerIdleNotifier], _getActiveRequests: [Function: _getActiveRequests], _getActiveHandles: [Function: _getActiveHandles], reallyExit: [Function: reallyExit], abort: [Function: abort], chdir: [Function: chdir], cwd: [Function: cwd], umask : [Function: umask ], getuid: [Function: getuid], geteuid: [Function: geteuid], setuid: [Function: setuid], seteuid: [Function: seteuid], setgid: [Function: setgid], setegid: [Function: setegid], getgid: [Function: getgid], getegid: [Function: getegid], getgroups: [Function: getgroups], setgroups: [Function: setgroups], initgroups: [Function: initgroups], _kill: [Function: _kill], _debugProcess: [Function: _debugProcess], _debugEnd: [Function: _debugEnd], hrtime: [Function: hrtime], cpuUsage: [Function: cpuUsage], dlopen: [Function: dlopen], uptime: [Function: uptime], memoryUsage: [Function: memoryUsage], _rawDebug: [Function], moduleLoadList: [ 'Binding contextify' , 'NativeModule events' , 'NativeModule internal/async_hooks' , 'NativeModule internal/errors' , 'Binding uv' , 'Binding buffer' , 'Binding async_wrap' , 'Binding config' , 'Binding icu' , 'NativeModule util' , 'NativeModule internal/encoding' , 'NativeModule internal/util' , 'Binding constants' , 'Binding util' , 'NativeModule internal/util/types' , 'Internal Binding types' , 'NativeModule buffer' , 'NativeModule internal/buffer' , 'NativeModule internal/process' , 'NativeModule assert' , 'NativeModule internal/assert' , 'NativeModule fs' , 'NativeModule path' , 'NativeModule internal/constants' , 'Binding fs' , 'NativeModule stream' , 'NativeModule internal/streams/pipeline' , 'NativeModule internal/streams/end-of-stream' , 'NativeModule internal/streams/legacy' , 'NativeModule _stream_readable' , 'NativeModule internal/streams/buffer_list' , 'NativeModule internal/streams/destroy' , 'NativeModule internal/streams/state' , 'NativeModule _stream_writable' , 'NativeModule _stream_duplex' , 'NativeModule _stream_transform' , 'NativeModule _stream_passthrough' , 'Binding fs_event_wrap' , 'NativeModule internal/fs/utils' , 'NativeModule internal/url' , 'NativeModule internal/querystring' , 'Binding url' , 'NativeModule internal/process/warning' , 'NativeModule internal/process/next_tick' , 'NativeModule internal/process/promises' , 'NativeModule internal/fixed_queue' , 'NativeModule internal/process/stdio' , 'Binding performance' , 'Binding trace_events' , 'NativeModule internal/inspector_async_hook' , 'Binding inspector' , 'NativeModule timers' , 'Binding timer_wrap' , 'NativeModule internal/linkedlist' , 'NativeModule internal/timers' , 'NativeModule internal/modules/cjs/loader' , 'NativeModule vm' , 'NativeModule internal/modules/cjs/helpers' , 'NativeModule console' , 'Binding tty_wrap' , 'NativeModule net' , 'NativeModule internal/net' , 'Binding cares_wrap' , 'Binding stream_wrap' , 'Binding tcp_wrap' , 'Binding pipe_wrap' , 'NativeModule internal/stream_base_commons' ], binding: [Function: binding], _linkedBinding: [Function: _linkedBinding], _events: { newListener: [Function], removeListener: [Function], warning: [Function] }, _eventsCount: 3, _maxListeners: undefined, _fatalException: [Function], domain: null, _exiting: false , assert: [Function: deprecated], config: { target_defaults: [Object], variables: [Object] }, setUncaughtExceptionCaptureCallback: [Function], hasUncaughtExceptionCaptureCallback: [Function], emitWarning: [Function], nextTick: [Function: nextTick], _tickCallback: [Function: _tickCallback], stdout: [Getter], stderr: [Getter], stdin: [Getter], openStdin: [Function], exit : [Function], kill : [Function], argv0: '/usr/local/bin/node' , mainModule: Module { id : '.' , exports: {}, parent: null, filename: '/Users/00arunalldata00/009_mystudy/010_everest/001_Everest4/20180628/201804/7.fs/11.fn.js' , loaded: false , children: [], paths: [Array] } }, Buffer: { [Function: Buffer] poolSize: 8192, from: [Function: from], of: [Function: of], alloc: [Function: alloc], allocUnsafe: [Function: allocUnsafe], allocUnsafeSlow: [Function: allocUnsafeSlow], isBuffer: [Function: isBuffer], compare: [Function: compare], isEncoding: [Function: isEncoding], concat: [Function: concat], byteLength: [Function: byteLength], [Symbol(kIsEncodingSymbol)]: [Function: isEncoding] }, clearImmediate: [Function: clearImmediate], clearInterval: [Function: clearInterval], clearTimeout: [Function: clearTimeout], setImmediate: { [Function: setImmediate] [Symbol(util.promisify.custom)]: [Function] }, setInterval: [Function: setInterval], setTimeout: { [Function: setTimeout] [Symbol(util.promisify.custom)]: [Function] } } */ |
分类:
007_WEB前端
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· 一次Java后端服务间歇性响应慢的问题排查记录
· 《HelloGitHub》第 108 期
· Windows桌面应用自动更新解决方案SharpUpdater5发布
· 我的家庭实验室服务器集群硬件清单
· Supergateway:MCP服务器的远程调试与集成工具
· C# 13 中的新增功能实操