javascript - String as a Single value and Array as multiple value handling -
if select 1 value getting value
val : "abc"
but if select multiple value val comming in array
val : ["abc","def"].
now because of problem neighther can work on single value nor multiple. can tell me how handle this.
eg:
var myobj = { data : "m1", val : "abc" }
after adding value become
var myobj = { data : "m2", val : abc,def }
function handleval(val){ if ("string" === typeof val){ console.log("do sth string"); } else if (array.isarray(val)){ console.log("do sth array") } } handleval("abc"); handleval([1,2])
Comments
Post a Comment