You're not initializing your variable, so its value is undefined
. Concatenating a string coerces it to the string "undefined"
before the concatenation.
Consider:
var x
alert(x + "test") // undefinedtest
Instead, initialize your variable to an empty string before performing concatenation:
var x = ""
alert(x + "test") // test
Note that functionally it is much cleaner to first extract the property you're interested in and then simply join
them together:
$.map(vendor, function (v) { return v.vendor_id }).join('')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…