【发布时间】:2017-03-18 17:37:27
【问题描述】:
在这段代码中,未定义是什么意思?没有指定 undefined 它说“我的名字是未定义的,我是一个未定义的”
(function(){
'use strict';
function theFunction(name, profession) {
console.log("My name is " + name + " and I am a " + profession + " . ");
}
theFunction("John", "fireman");
theFunction.apply(undefined,["ali", "Developer"]);
theFunction.call(undefined, "sara", "doctor");
}());
【问题讨论】:
-
请参阅:stackoverflow.com/questions/5247060/… 这样您就不会更改
this的值。 -
“如果不指定 undefined,它会说“我的名字是未定义的,我是未定义的”” 在哪里?
-
我认为OP的意思是,如果他在使用apply或call时不添加
undefined作为第一个参数。正确答案如下。
标签: javascript call apply