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)
hasOwnProperty Vote_lcaphasOwnProperty Voting_barhasOwnProperty Vote_rcap 
Mr.Easybb (1587)
hasOwnProperty Vote_lcaphasOwnProperty Voting_barhasOwnProperty Vote_rcap 
Bloodbath (745)
hasOwnProperty Vote_lcaphasOwnProperty Voting_barhasOwnProperty Vote_rcap 
Rukiafan (533)
hasOwnProperty Vote_lcaphasOwnProperty Voting_barhasOwnProperty Vote_rcap 
Dom (513)
hasOwnProperty Vote_lcaphasOwnProperty Voting_barhasOwnProperty Vote_rcap 
puppycheese (446)
hasOwnProperty Vote_lcaphasOwnProperty Voting_barhasOwnProperty Vote_rcap 
pedro (330)
hasOwnProperty Vote_lcaphasOwnProperty Voting_barhasOwnProperty Vote_rcap 
Neymar (301)
hasOwnProperty Vote_lcaphasOwnProperty Voting_barhasOwnProperty Vote_rcap 
Hitsu (281)
hasOwnProperty Vote_lcaphasOwnProperty Voting_barhasOwnProperty Vote_rcap 
Flora (275)
hasOwnProperty Vote_lcaphasOwnProperty Voting_barhasOwnProperty Vote_rcap 


hasOwnProperty

gillgill
Status : Syntax highlighter's colors are nice.

Posts : 78
Join date : 2014-04-05
Fri 27 Mar 2015, 07:16
Currently I'm working on some script and I need a little help here. How can I make a [ic]window.hasOwnProperty[/ic] method?

Like this :

Code:
[panda=js]function foo(x) {
 return x;
}

window.hasOwnProperty(foo);
HitsuHitsu
Status : Finished on working fmAPI.

Posts : 281
Join date : 2013-09-09
Age : 25
Location : Indonesia
Fri 27 Mar 2015, 07:24
[ic]window.hasOwnProperty[/ic] only works for variables, as far as I known.
If you're interested to check for an existing wrapper function, maybe you can use this :

Code:
[panda=js]function foo(x) {
 return x;
}

if( foo ) {
 console.log('Hey..');
}else{
 console.log('Unavailable. LOL XD');
}
BloodbathBloodbath
Status : No status yet...

Posts : 745
Join date : 2013-05-31
Age : 28
Fri 27 Mar 2015, 08:02
Try this...

Code:
Object.prototype.hasOwnProperty.call(window, property);

You could alternatively do this:

Code:
function windowHasProperty(x){
 return (x in window) && true || false;
}

If possible use the first method.
Sponsored content