risk of javascript undefined variable

阅读更多
var objFiles = [{"name": "FileA"},{"name": "FileB"}];
var strHtml; //undefined

$.each(objFiles, function(i, v){
	strHtml += '

'+v.name+'

'; }); console.log(strHtml); //undefined

FileA

FileB



var objFiles = [{"name": "FileA"},{"name": "FileB"}];
var strHtml  = '';

$.each(objFiles, function(i, v){
	strHtml += '

'+v.name+'

'; }); console.log(strHtml); //

FileA

FileB

你可能感兴趣的:(risk of javascript undefined variable)