简体   繁体   中英

how can I get nested Scope properties with a get()

I have the following problem: I need to get Scope properties with .get(myparameter) , to call it in a function.

var myobj = new Object();
myobj.vname = "firstname"
myobj.lname = "lastname"
sessionScope.Me = myobj;
print (sessionScope.Me.vname)
print (sessionScope.Me.get("vname"))

The first print is okay, but the second throws this error:

Error calling method 'get(string)' on an object of type 'Object [JavaScript Object]'

For Javascript, use an indexer.

print (sessionScope.Me["vname"])

There is no get function on your Me object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM