Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

settype in javascript?

Posted on 2006-05-18
4
Medium Priority
?
1,239 Views
Last Modified: 2008-03-10
What can I use in Javascript to do the equiv. of PHP's settype($foo, 'boolean');
0
Comment
Question by:mnb93
2 Comments
 
LVL 3

Accepted Solution

by:
vincent_figo earned 252 total points
ID: 16707070
Javascript doesn't really work with types. Variable types are not important in JavaScript. They may be interchanged as necessary. This means that if a variable is a string one minute, it can be an integer the next. So i don't think it is possible to set a type to a specific variable...
0
 
LVL 63

Assisted Solution

by:Zvonko
Zvonko earned 248 total points
ID: 16707208
As vincent stated, you cannot set the var type alone. You set the var type by setting the var value. The var type is then acording to the value type. If no value in the var, then also the type of the var is of type "undefined"
For your example you set the type like this:

var $foo = true; // now is $foo of type Boolean



0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question