As far as I'm aware, i makes no difference, as you can start a variable name in Javascript with anything you like...
If you've seen it in one of my scripts, it's a leftover habit because I've been doing a lot of PHP currently, and that requires that all variables begin with a $. As it (as far as I know) makes no difference, I use it to save mistakes in PHP.
Help from me is always guaranteed!*
VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.
Help from me is always guaranteed!*
VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.
Pet.prototype.name;
-OR-
Pet.prototype.name = "NO NAME";
As for a static class, I'll throw you a really complex example - it's a UTF-8 encoder:
Some of the syntax is wierd - I think there using one of the JavaScript variants.
Code:
var Url = {
encode : function (string) {
return escape(this._utf8_encode(string));
},
decode : function (string) {
return this._utf8_decode(unescape(string));
},
_utf8_encode : function (string) {
//Code removed for sanity's sake
},
_utf8_decode : function (utftext) {
//Code removed for sanity's sake
}
}
s = Url.encode(s)
Help from me is always guaranteed!*
VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.
The $ (dollar sign) is a custom function. It is not for regex, nor does it have anything to do with PHP.
It was created a few years back to make the process of finding/getting elements much simpler. Take a look at this post from my website. It clarifies this well.
Code:
(statement) ? true : false;
This is known as ternary logic. Nice and simple. It takes an if statement to one line and makes the processing much faster.
Originally Posted by code?
How would I type up a static class in javascript, So I could easily write...
Let's make this much simpler...try using objects. They go hand in hand with classes.
Code:
var myObject = {
myFunction = function(str) {
alert(str);
},
myRandomVariable: 'Hello world!'
}
// then to call it
myObject.myFunction('Hello world!');
Last edited by PeejAvery; August 11th, 2008 at 08:03 AM.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Bookmarks