Oolite Bulletins
http://bb.aegidian.org/

missionVariables and hasOwnProperty
http://bb.aegidian.org/viewtopic.php?f=4&t=18905
Page 1 of 1

Author:  herodotus [ Mon Jul 17, 2017 11:03 am ]
Post subject:  missionVariables and hasOwnProperty

Hi,

I've been debugging a broken OXP and I got a bit confused about the behaviour of the missionVariables object. The OXP I'm looking at checks to see if a missionVariable exists using missionVariables.hasOwnProperty('mission_prop');. This is probably redundant in the case in question anyway, but it seems like this returns false even if the property does exist and has a value. Does missionVariables use some dark JS magic that prevents properties showing up to hasOwnProperty? If not it's possible that I'm just getting confused, but I thought I'd check before I waste any more time trying to work out what's going on!

Cheers,

Author:  phkb [ Mon Jul 17, 2017 10:42 pm ]
Post subject:  Re: missionVariables and hasOwnProperty

I ran this test:
Code:
	log(this.name, "test 1 " + (missionVariables.hasOwnProperty("myTest") === true ? "yes" : "no"));
	missionVariables.myTest = "hello world";
	log(this.name, "test 2 " + (missionVariables.hasOwnProperty("myTest") === true ? "yes" : "no"));
The output was:
Code:
	test 1 no
	test 2 yes
So on the surface at least it seems to work.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/