나는이 함수를 가지고있다.할당 된 변수 유형이 숫자 인 이유는 무엇입니까?
var myfuncsettings;
var myfunc = function(settings) {
myfuncsettings = settings | {};
myfuncsettings['prop'] = 'test';
};
오류가 발생했습니다.
Uncaught TypeError: Cannot create property 'message' on number '0'(…)
I consoled.
var myfuncsettings;
var myfunc = function(settings) {
console.log('typeof settings: ' + (typeof settings));
myfuncsettings = settings | {};
console.log('typeof myfuncsettings: ' + (typeof myfuncsettings));
myfuncsettings['message'] = 'test';
};
그리고 있어요.
typeof settings: object
typeof myfuncsettings: number
아무도 내가 뭘 잘못했는지 말해 줄 수 있습니까?
내가 다운 표를 이해를 참조하십시오 찾고 있습니다. 그러나이 질문은 폐회 할 자격이 없습니다. –
나는 이것이 '인쇄 상 오류'로 간주하지 않습니다. 하나의 파이프가 완벽하게 유효합니다. OP가 원하는 것과 다른 것을 수행합니다. – musefan
나는 downvotes를 이해하지 않는다. 당신은 당신의 문제를 매우 잘 설명했습니다. – musefan