/    Sign up×
Community /Pin to ProfileBookmark

‘Undefined’ is null or not an object

Hi,

How do I return true, if the error message ‘undefined’ is null or not an object ‘ occours?

I have tried with the following code, but I still get the error:

function ean( ean ){

var reg = /<%=obj_payment.getRegularExp()%>/;

if ( typeof( reg ) != undefined ){

return reg.test( ean );

}
else {

return true;

}
}

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@mrhooOct 06.2006 — You know you want reg to be in the form of a regular expression,

so test for a regular expression:

if ( typeof( reg ) == 'RegExp' ){

return reg.test( ean );

}
Copy linkTweet thisAlerts:
@felgallOct 06.2006 — if ( typeof( reg ) != [b]'[/b]undefined[b]'[/b] ){
×

Success!

Help @jeppe spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...