Like SystemiConnectFri 15 Oct 2021, 04:50
Auto Save MessagesLGforumFri 26 Feb 2021, 13:31
New tutorial questionTheCrowMon 15 Feb 2021, 08:12
Support iOS Emojis (and other platforms)LGforumSun 14 Feb 2021, 01:25
LGforum (2806)
Return string instead of [object Object] Vote_lcapReturn string instead of [object Object] Voting_barReturn string instead of [object Object] Vote_rcap 
Mr.Easybb (1587)
Return string instead of [object Object] Vote_lcapReturn string instead of [object Object] Voting_barReturn string instead of [object Object] Vote_rcap 
Bloodbath (745)
Return string instead of [object Object] Vote_lcapReturn string instead of [object Object] Voting_barReturn string instead of [object Object] Vote_rcap 
Rukiafan (533)
Return string instead of [object Object] Vote_lcapReturn string instead of [object Object] Voting_barReturn string instead of [object Object] Vote_rcap 
Dom (513)
Return string instead of [object Object] Vote_lcapReturn string instead of [object Object] Voting_barReturn string instead of [object Object] Vote_rcap 
puppycheese (446)
Return string instead of [object Object] Vote_lcapReturn string instead of [object Object] Voting_barReturn string instead of [object Object] Vote_rcap 
pedro (330)
Return string instead of [object Object] Vote_lcapReturn string instead of [object Object] Voting_barReturn string instead of [object Object] Vote_rcap 
Neymar (301)
Return string instead of [object Object] Vote_lcapReturn string instead of [object Object] Voting_barReturn string instead of [object Object] Vote_rcap 
Hitsu (281)
Return string instead of [object Object] Vote_lcapReturn string instead of [object Object] Voting_barReturn string instead of [object Object] Vote_rcap 
Flora (275)
Return string instead of [object Object] Vote_lcapReturn string instead of [object Object] Voting_barReturn string instead of [object Object] Vote_rcap 


Return string instead of [object Object]

HitsuHitsu
Status : Finished on working fmAPI.

Posts : 281
Join date : 2013-09-09
Age : 25
Location : Indonesia
Fri 29 Apr 2016, 09:10
Hello there! It's been a long time.

It's just a simple question tho.

Code:
var data = {
    name:"You-Know-Who",
    age:100
}

function exFunc(a, b) {
    alert('Hello, ' + this + 'and ' + this);
}

exFunc.call(data.toString());

My question is: how to make it returns You-Know-Who and 100 instead of [object Object]?

And also, sorry for the soooo noobish question. I'm not into coding for a long time (about 1 year long) because I've reached last year in school, so I've focused at studying.

Thanks for your answer! *winks*
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Fri 29 Apr 2016, 09:39
No problem!

So 'data' is the object and 'name' and 'age' are its properties.
To access the value of the properties the most common method is through what is called dot notation.
Like so: [ic]data.name[/ic]
So it is this that you are missing in your code.

So [ic]'Hello ' + data.name + ', your age is ' + data.age + ' isn't it?'[/ic]

Hope that helps!
HitsuHitsu
Status : Finished on working fmAPI.

Posts : 281
Join date : 2013-09-09
Age : 25
Location : Indonesia
Sun 01 May 2016, 03:14
Thanks! It worked. /w\
avatarGuest
Wed 04 May 2016, 20:08
Moved to the archives, since it's solved.
Sponsored content