Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-08-2006, 07:51 PM   PM User | #1
Thompson
New Coder

 
Join Date: Mar 2006
Location: São Paulo, Brazil
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Thompson is an unknown quantity at this point
Variables that don´t exists in the code

Hi, folks.

Take a look in this situation: i want to see the value of a variable that do not exists in the script, like the example below:

Code:
<script>
    alert(size);
</script>
if i run this, the browser will show "undefined" on the alert window.
correction: the Internet Explorer, at least, should display this on the screen.

But what about the others browsers?? Anyone know if the value "undefined" is given to all the things that was not declared in the code? Opera, Firefox, Netscape, they should give the same result??

Thanks for the answers.
__________________
----
As coisas mais simples são as mais importantes.
---------
Thompson M1A1: D-Day
----------------
Thompson is offline   Reply With Quote
Old 05-08-2006, 07:53 PM   PM User | #2
Beagle
Senior Coder

 
Join Date: Jul 2005
Location: New York, NY
Posts: 1,084
Thanks: 4
Thanked 19 Times in 19 Posts
Beagle is an unknown quantity at this point
undefined is the ecma script standard for undefined variables. So browsers SHOULD give you the same result.

Always test though.
Beagle is offline   Reply With Quote
Old 05-08-2006, 08:22 PM   PM User | #3
Thompson
New Coder

 
Join Date: Mar 2006
Location: São Paulo, Brazil
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Thompson is an unknown quantity at this point
Wow, i didn´t know about this ecma specification. Looking their documentation, it should answer some of my questions.

Thanks
__________________
----
As coisas mais simples são as mais importantes.
---------
Thompson M1A1: D-Day
----------------
Thompson is offline   Reply With Quote
Old 05-08-2006, 09:34 PM   PM User | #4
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
The ECMAScript specification isn't really written with the programmer as the target - it's written for those programming ECMAScript engines, in highly technical lingo. So, unless you're experienced with that type of documents, I would advice you to search information elsewhere, for example in the JavaScript documentation and references on devmo.

For this case though:

- The engine will search the local scope for any variables bound using a with or within a function body. It will then search the global object(-s). If not found, it will create a new temporary variable. Variables are by default set to undefined, so all variables that have not been initialized will contain that value. If you are writing to this temporary variable, the engine will make it into a real variable in the global scope.
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

Last edited by liorean; 05-08-2006 at 09:39 PM..
liorean is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:59 PM.


Advertisement
Log in to turn off these ads.