![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
That's a wrong statement, you must be thinking of VBScript where indeed all variables independently on the current value are of the same Variant type. JavaScript is a *loosely typed* language, that means that each variable is of some certain type but this type can be changed to another one at runtime. I doubt anyone is thinking of VBScript at this juncture. *And you aren't thinking at all (as usual). |
#12
| ||||||
| ||||||
|
|
Variables can have types in JavaScript 2.0, but not in ECMAScript so far. Values have types. Variables have a value, but not an inherent type. |
but so far|
Null is a primitive value in javascript. Another wrong statement: null in JavaScript is an object with the only property null: *window.alert(typeof null) // 'object' No, null is a primitive (i.e., non-object) value. Notice the specification of the typeof operator needs a special case for null, because it is not an object (ECMA 262 section 11.4.3). |
|
This way by assigning null to an object reference, we are dereferencing the said object. You can't assign a value to a value (object references are values), and I don't think "dereferencing" means what you think it means. |
|
If it is the last existing reference then the relevant scavenger will be marked as garbage collection available on the next GC check. Not sure what is so alien here in comparison with other languages. True, if you overwrite a variable holding an object reference with null, that might make the object eligable for garbage collection, but the same happens if you assign a number to the variable. Nothing non-primitive about null in that case. |
|
| Another misleading assertion was — "Though ECMA-262 doesn’t indicate a | way to access the Global object directly […]". Plainly false. In global context: var global = this; Plainly false: in global context [this] refers to the window host object, not to Global. What makes you think they are different? ![]() |
|
In a browser setting, the global object and the "this" value is actually not necessarily the same object, but ECMA-262 says nothing about browsers. It does say that the "this" value for code executed in a Global Context is the global object. If browsers differ, it's because they are not completely ECMA-262 compliant (with good reason, usually security related). |
#13
| |||
| |||
|
What makes you think they are different? ![]() |

|
In a browser setting, the global object and the "this" value is actually not necessarily the same object, but ECMA-262 says nothing about browsers. It does say that the "this" value for code executed in a Global Context is the global object. If browsers differ, it's because they are not completely ECMA-262 compliant (with good reason, usually security related). |
#14
| ||||||||||||
| ||||||||||||
|
|
Garrett Smith wrote: Javascript variables are untyped. |
|
That's a wrong statement, you must be thinking of VBScript where indeed all variables independently on the current value are of the same Variant type. JavaScript is a *loosely typed* language, that means that each variable is of some certain type but this type can be changed to another one at runtime. |
|
A string value is a member of the type String |
|
every variable and every expression has a type that is known at compile time. Types limit the values that a variable (§4.12) can hold or that an expression can produce, limit the operations supported on those values, and determine the meaning of the operations. Strong typing helps detect errors at compile time. |
|
Null is a primitive value in javascript. Another wrong statement: null in JavaScript is an object with the only property null: |
|
4.3.12 Null Type The type Null has exactly one value, called null. 4.3.2 Primitive Value A primitive value is a member of one of the types Undefined, Null, Boolean, Number, or String |
|
Input Type Result Undefined The result equals the input argument (no conversion). Null The result equals the input argument (no conversion). ... |
|
7.8.1 The value of the null literal null is the sole value of the Null type, namely null. |
|
note that null is not an object window.alert(typeof null) // 'object' |
|
This way by assigning null to an object reference, we are dereferencing the said object. If it is the last existing reference then the relevant scavenger will be marked as garbage collection available on the next GC check. Not sure what is so alien here in comparison with other languages. I'm having a hard time following that explanation. |
|
| Another misleading assertion was — "Though ECMA-262 doesn’t indicate a | way to access the Global object directly […]". Plainly false. In global context: var global = this; Plainly false: in global context [this] refers to the window host object, not to Global. Let's do not mix "syntax sugar" added atop in some engine implementations with the actual mechanics, it might be dangerous. |
|
The |this| value is the global object. |
#15
| |||
| |||
|
|
That's a wrong statement, you must be thinking of VBScript where indeed all variables independently on the current value are of the same Variant type. JavaScript is a *loosely typed* language, that means that each variable is of some certain type but this type can be changed to another one at runtime. |
|
No, my statement is correct. Variables are untyped. Nowhere are variables defined to have a type. |

#16
| |||
| |||
|
|
You know guys, at the run of one week you just killed me, really. For some time I did believe that some posters here are professional programmers with CS diplomas trying to learn yet another language different from C++. So I attributed their obvious beserknesses to the classical CS education - so being forgiven to some rather wide extend. But the discussion at "Implicit object constructor misinterpretation" and comments like here did force me to change my mind. Now if I ever believe that you had any CS education, then only in some conspiratorial school "Witnesses of Integer" or similar of the kind ![]() Because no normal place you could came from with such a luggage of pseudo-philosophic twisted definitions of nearly anything from the the most core programming entities. |
|
For other possible readers a few random links on the subject below. Also of course do not take some anonymous VK poster as being right by definition. Go and ask at MIT, Berkley, Carnegie Mellon or other reputable CS department for explanations. Typeless language http://www.microsoft.com/technet/scriptcenter/guide/sas_vbs_eves.mspx |
|
Loosely (dynamically) typed language http://www.computerhope.com/jargon/l/looslang.htm http://msdn.microsoft.com/en-us/library/14cd3459%28VS.85%29.aspx http://www.java2s.com/Tutorial/JavaScript/0100__Number-Data-Type/Variablesarelooselytyped.htm see also: type coercion Strongly (statically) typed language http://www.computerhope.com/jargon/s/strolang.htm |
#17
| ||||
| ||||
|
|
Nothing like abuse to make people shut up. Just don't mistake silence for agreement after it, though. |
|
Anyway, if everybody else disagrees with you, perhaps you should entertain the idea that it might not be all of them who are in the wrong. |
|
Wars have been fought over the meaning of "strongly typed". Is it the same as "statically typed" or does it mean that values can't change their type, or one of the other six interpretations given at URL:http://en.wikipedia.org/wiki/Strongly_typed_programming_language>? You are very strict in your insistence that Javascript is "loosely typed", which is a name that is not even mentioned at *<URL:http://en.wikipedia.org/wiki/Type_system I can see that it is a term often used about "scripting like" languages, to mean that you don't declare a variable to have a type, and you can assign values of different types to the same variable. Given the disagreement about "strongly typed", I can see the need for a different name (other than "weakly typed") for this property. |
|
You then insist that variables have types |
#18
| |||||||||||||
| |||||||||||||
|
|
VK wrote: That's a wrong statement, you must be thinking of VBScript where indeed all variables independently on the current value are of the same Variant type. JavaScript is a *loosely typed* language, that means that each variable is of some certain type but this type can be changed to another one at runtime. Garrett Smith wrote: No, my statement is correct. Variables are untyped. Nowhere are variables defined to have a type. (further similar nonsense removed) |
|
You know guys, at the run of one week you just killed me, really. For some time I did believe that some posters here are professional |
|
programmers with CS diplomas trying to learn yet another language different from C++. So I attributed their obvious beserknesses to the classical CS education - so being forgiven to some rather wide extend. But the discussion at "Implicit object constructor misinterpretation" and comments like here did force me to change my mind. Now if I ever believe that you had any CS education, then only in some conspiratorial school "Witnesses of Integer" or similar of the kind ![]() Because no normal place you could came from with such a luggage of pseudo-philosophic twisted definitions of nearly anything from the the most core programming entities. |
|
I am not arguing with you anymore. You are definitely right, the Earth is flat and stays on three elephants. |
|
For other possible readers a few random links on the subject below. Also of course do not take some anonymous VK poster as being right by definition. Go and ask at MIT, Berkley, Carnegie Mellon or other reputable CS department for explanations. |
|
Typeless language http://www.microsoft.com/technet/scriptcenter/guide/sas_vbs_eves.mspx |
|
Loosely (dynamically) typed language http://www.computerhope.com/jargon/l/looslang.htm |
|
http://msdn.microsoft.com/en-us/library/14cd3459%28VS.85%29.aspx |
|
You cannot explicitly declare data types in JScript. |
|
variable is of some certain type but this type can be changed to another one at runtime |
|
http://www.java2s.com/Tutorial/JavaScript/0100__Number-Data-Type/Variablesarelooselytyped.htm see also: type coercion |
|
variables in JavaScript are not given a specific type. |
|
variable is of some certain type Strongly (statically) typed language http://www.computerhope.com/jargon/s/strolang.htm |
#19
| |||
| |||
|
|
You know guys, at the run of one week you just killed me, really. ... But the discussion at "Implicit object constructor misinterpretation" and comments like here did force me to change my mind. snip |
#20
| |||
| |||
|
|
You're just upset that no-one wants to believe your complicated and incoherent description instead of our simple and clear version. ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
![]() |
| Thread Tools | |
| Display Modes | |
| |