If I have a variable of some sort, say x, how can I find out what
variable type javascript thinks it is? For example, if I've declared x
as 5 earlier, how do I know now whether it's a string or a number,
isNaN returns false, regardless of whether I declared it as "5" or 5. 4 10302
mouseit said:
> If I have a variable of some sort, say x, how can I find out what variable type javascript thinks it is? For example, if I've declared x as 5 earlier, how do I know now whether it's a string or a number, isNaN returns false, regardless of whether I declared it as "5" or 5.
Javascript doesn't think it needs to know.
Why do you think you do?
--
mouseit wrote:
If I have a variable of some sort, say x, how can I find out what
variable type javascript thinks it is? For example, if I've declared x
as 5 earlier, how do I know now whether it's a string or a number,
isNaN returns false, regardless of whether I declared it as "5" or 5.
typeof or instanceof.
typeof will give the generic object type.
instanceof will only return true if it is an object of type [Object].
([Object] being any valid JavaScript Object; String, Function, Array,
Object, whatever.)
--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
mouseit wrote:
If I have a variable of some sort, say x, how can I find out what
variable type javascript thinks it is? For example, if I've declared x
as 5 earlier, how do I know now whether it's a string or a number,
isNaN returns false, regardless of whether I declared it as "5" or 5.
typeof 5 === 'number'
typeof '5' === 'string' http://javascript.crockford.com/survey.html
On May 26, 8:58 pm, Douglas Crockford <nos...@sbcglob al.netwrote:
mouseit wrote:
If I have a variable of some sort, say x, how can I find out what
variable type javascript thinks it is? For example, if I've declared x
as 5 earlier, how do I know now whether it's a string or a number,
isNaN returns false, regardless of whether I declared it as "5" or 5.
typeof 5 === 'number'
typeof '5' === 'string'
http://javascript.crockford.com/survey.html
Thank you all! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike Kamermans |
last post by:
Is there a way to determine what a node() find returns? For instance, if
I have a snip of XSLT that looks like:
<xsl:for-each select="node()">
...
</xsl:for-each>
Is there a way to, for each node found, generate what kind of node it
found, like <some_element> or <#PCDATA> or something that indicates the
type of element it found?
|
by: Trevor M. Lango |
last post by:
The number of arguments passed to the following functions can be
determined - but how is this coded?
main (int argc, char *argv)
printf ( string format )
I would like to be able to write arbitrary functions that know how many
arguments were passed to them.
|
by: Steve Brown |
last post by:
Hello all,
Is there a way to determine a variable's type at run-time? The reason
I'm asking is that i have code that looks like this:
template <class T>
Object::Object(int TypeCode, T* data)
{
switch (TypeCode)
case 1:
|
by: CTDev Team |
last post by:
Hi,
We are using Exchange Server 5.5, and have applications written in VB6 and
C# that read and process emails.
We are experiencing intermittent errors similar to
C# Application
System.Runtime.InteropServices.COMException (0x80004005): The client
|
by: petermichaux |
last post by:
Hi,
I'm hoping for a reason I'm wrong or an alternate solution...
I'd like to be able to dynamically include some javascript files. This
is like scriptaculous.js library but their solution is broken in
Firefox 1.5.0.1 on OS X. What happens with the Scriptaculous library is
this
In the html document the author only has to include one line
| |
by: Doug Stiers |
last post by:
C# newbie question:
I'm trying to determine the type of a datareader value. Why cant I do it
like this?
if (rdr.GetValue(0).GetType() is Guid || rdr.GetValue(0).GetType() is
Int32)
{
// do something
}
|
by: Schraalhans Keukenmeester |
last post by:
I have some C functions (with variable length argument lists) that use
void pointers as arguments.
Is there a way to determine at runtime what type of parameter is
actually passed on to the function? PHP and my oldskool turbopascal
provide a typeof() function, but my C compiler (gcc 3.4.1) does not seem
to provide this function. Perhaps someone crafted a library with some
smart code able to inspect the variable passed to a certain...
|
by: Jeremy |
last post by:
Does anyone have a clever algorithm for generating an outline of the
current document from (client-side) javascript using DOM methods?
For example, let's say I predictably have a document structured
hierarchically with <h1>...<h6tags. I want to generate an outline of
the document wherein I have nested lists of the contents of the headers.
Take for example the following snippet of a fictional legal document:
------------
<h1>Main...
|
by: pob |
last post by:
I was all happy because thru some tutelage of others I created this
array to find the newest file in a directory. However, I then
realized its great that I now know the latest file, but I need to know
the name of the file. Unfortunately, I am only passing the date into
the array.
Do I need to create a m-d array ? If so how do I create a 2-d array
where I do not know how many rows I will be looping thru ?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |