Nov 21, 2009

Lesser Known Useful Javascript Features

free web hosting
Open Discussion > MODERATED AREA > Tutorials

Lesser Known Useful Javascript Features

delivi
Variables
Javascript assigns every variable a type which changes as we assign different values to the variable. We can get the type of a variable using the 'typeof' operator.

For eg.,
CODE
var hello = "Welcome to Trap17";
var year = 2008;

alert(typeof hello );
alert(typeof year );


The above lines will output the type of the first variable 'hello' as String and the second variable 'year' as Number.

The types of Javascript variables are Boolean, Function, Number, Object and String.

A variable with no explicitly assigned value has a value 'undefined'.

'===' Operator
The === Operator (with three equals signs), always returns 'false ' if two operands are of different types and performs the operation of '==' operator if they are of same type. So the '===' is used to strictly compare two operands that are of same type.

CODE
var a = 123;     //Number
var b = "123";  //String

alert( a == b );
alert( a === b );


the first output returns true as it just compares the value and ignores the tpe of the variables, whereas the second expression outputs 'false' as the two variables are of different types.

for-in
Javascript has a for similar to the one found in other programming languages. It also has a variant of the 'for' that can be used to iterate over the properties of an object or to iterate over arrays.

CODE
var rainbow = [ "Violet" , "Indigo" , "Blue" , "Green" , "Yellow" , "Orange" , "Red" ];

for ( var color in rainbow )
   alert(colors[color]);

 

 

 


Comment/Reply (w/o sign-up)

trontron
Wow! Thanks for the enlightenment. I have used JavaScript before but there are just so many operators which provide quite a huge number of possibilities and can dramatically increase the functionality of your website. However quite a lot of people don't trust Java since it can be used in wrong and harmful ways. sad.gif

Nonetheless, I recommend that people check out the W3Schools website to help learn java as it is an well crafted resource for beginners. After you start to get the hang of it you'll wish that you learned it earlier. tongue.gif

Comment/Reply (w/o sign-up)

Forbez
Yeah, this is a good tutorial. I also agree, w3schools is a great resource for learning more about javascript. Nevertheless, this tutorial is so really good.

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : lesser, javascript, features

  1. Make A Moderately-secure Password System Using Javascript
    using file redirection to hide the password. (11)
  2. Simple Javascript And Password System
    How to protect your pages with password (10)
    The quickest way to get a password protection system up and running is to use a Prompt box in
    JavaScript that has a title like "Enter your Email Address". Only you and the relevant users know
    what the password should be, could even be one each, that can be sorted out at the next page then
    pass the "input" directly through the url by changing the .href, like
    http://www.iSource.net.nz/users/?leTmeIn= The page that then processes this should also check for
    the referring page, and three fails from an IP if you like the php (the next page): CODE //
    processdownloads.p....
  3. Create A Simple Html Editor With Php And Javascript
    (3)
    Ok, I will teach you how to create a simple HTML editor that runs online with buttons that add HTML
    tags. Before we start: You should have basic knowledge of these languages. HTML/XHTML
    Javascript PHP You will need Ability to use filesystem functions. Chmodding abilities
    Features of Editor Online PHP safe Full HTML support A Few Bad Features Can only create new
    documents or overwrite Fairly unsafe Now we are ready to begin. The PHP Script This will be
    our PHP script that we will use to make the file. Make a file called save.php Here is the....
  4. Mootools - My Favourite Javascript Library
    (3)
    It kind of amazes me that there's not even a mention of the Mootools javascript library
    throughout this whole forum. So here I'll do a brief introduction and a tutorial on how to
    produce the famous accordion effect. MooTools is a compact, modular, Object-Oriented javascript
    framework designed to make writing extensible and compatible code easier and faster. MooTools lets
    you get the job done efficiently and effectively. It is slightly based on the powerful Prototype
    javascript framework , of which Scriptaculous runs on. (But frankly, I dislike Scriptaculou....
  5. Javascript Scroll Bar
    A scroll bar for your webpage using javascript (13)
    In this tutorial I will show you how to create two buttons in the bottom left of the screen that,
    when hovered over, will scroll the page. Now to start with, we must create a our buttons, the first
    line will create a div element, or block. Using blocks you can position items anywhere on a page.
    We use the ID property just to let us know what the block is used for, as for the first block, its
    obvious that it contains the vertical buttons and the second two blocks contains the horizontal
    buttons. The style property of the div tag tells the browser how to draw it, in the....
  6. Simple Scripts In Html And Javascript
    Things like BackgroundColorChanger and so (7)
    like in the topic, here is a description how to change the Backgroundcolor "On The Fly", by klicking
    on a button or radio-box first, we ned the html-and body-tags, create a new html-file on your
    desktop and write the following: QUOTE browser interpretation: html - tag
    means "hey, browser, here comes HTML" in the body-tag you define the looking of your site. you can
    add things like "bgcolor" for the background, "text" for the textcolor and link / alink / hlink /
    vlink to define the linkcolor ( ) the scripttag is the tag, we'll need now (sorr....
  7. Features That You Can Use In The Shoutbox
    (5)
    Some people dont know all of the features that the shoutbox has so im going to write about it
    explaining it. Viewing Statistics In D21-Shoutbox 1.2 I have seen a few shouts in
    the shoutbox asking how to view the Statistics for the Shoutbox, and it is quite simple actually.
    First you need to click on "View The Shoutbox" which is located on the top bar of the Shoutbox,
    it is located right next to "Latest Shouts In The Shoutbox" Once you are there, look in the
    Trap17 Shoutbox section for My Control Panel Then it should be self ex....
  8. Javascript Framework - A Shortcut Javascript
    a shortcut javascript (3)
    hi, today im going to give you small tutorial how to use `Prototype JavaScript Framework` 1st you
    have to download `Prototype JavaScript Framework`library from http://prototype.conio.net/
    prototype makes easy to using Javascript, ex : when you want to point (get) the element from HTML
    usually we use : CODE document.getElementById('elementId') with prototype we use
    CODE $('elementId') , yeah...world getting small..with prototype. example we`re going
    to get value from an element of CODE with prototype we use CODE alert(....
  9. Tool Tips Using Only Css To Pop Up The Tool Tip
    No javascript involved! (8)
    Tool Tip Tutorial Example Found Here . Please review before continuing. Nice. And no
    javascript at all to be found. The colours I have used are for demonstration purposes only to show
    you that they are adjustable to suit the background or to contrast against them. Your choice. That
    is a styling issue. It is your site, you decide. The original author's idea was to add
    position:relative to the link, in order to allow the span element inside to position absolutely
    in respect to the parent link. This code has been tested in Ie5.5, IE6, Opera7.11 and M....
  10. Handy Javascript Code Snips
    Ready to Apply in your webpage (5)
    /tongue.gif' border='0' style='vertical-align:middle' alt='tongue.gif' /> Some common things to
    implement in our webpage very frequently are as follows. How to implement all these I am going to
    tell you in this tutorial. Add To Favorite Set As Homepage Go To Top Of Page No Right Click
    Print Page Adding Current Date Adding Current Time Pop-Up Page Creation Closing Window
    Copyright Notice Updation 01. Add To Favorite Someone may be interested in the content of your
    page. Offer him/her to add the page in his/her favorite menu. To do this you have ....
  11. Image Rollovers In Javascript
    A Write-Once, Use-Anywhere Approach (11)
    Tutorial: Image Rollovers w/ Javascript, by Rob J. Secord, B.Sc. (SystemWisdom) See a
    working Sample of this Script! Download a ZIP containing all working files in this tutorial!
    Note: If you are not interested in reading this entire tutorial and/or have a basic understanding of
    the underlying concepts, you may safely skip to the Implementation section to get the code!
    Description : A Dynamic Image Rollover Script tested to work in 4 major internet browsers: MSIE,
    FireFox, Netscape and Opera. Using only Javascript combined with regular HTML Images ( ....
  12. Css And Javascript Combined For Dynamic Layout
    use of different CSS files at same site (9)
    This tutorial is meant for people that are dealing with problems while coding their site at 100% of
    width. Important notice: Some people has JavaScript disabled, so they will not be able to load CSS
    file (take this in account when creating your website). How this script works. In the HEAD of your
    HTML document will apply this command, so variable.js file will be load at start: CODE
    In browser JavaScript file variable.js is loaded. This Javascript file consist of this parameters,
    copy this code and name it variable.js CODE // JavaScript Document if (sc....
  13. How To: Change An Image When A User Clicks On It
    using both php and javascript (12)
    How To: Change An Image When A User Clicks On It using both php and javascript - a powerful
    combination I have seen quite a few how tos offering a method of doing this but none of which
    resembled my method of making use of both php and javascript. This code is fairly repetitive and
    most of the functions are easy to pick-up if you haven't heard of them before. Here it is...
    Create your two images. Call them anything you like, you'd just need to change their filenames
    in $imgano $imgayes. In fact with this script you can easily create more than one pair....
  14. Creating Rollovers With Buttons
    Short & simple javascript tutorial that shows you how. (2)
    Javascript in action can render some very neat visual effects, which can make your website more
    appealing, and sometimes even easier to navigate. Among the most common effects are the
    'button' effect, and the mouseover effect. The buttons are very common, of course; if
    nowhere else, most of us have seen them at the end of forms (Click the 'submit' button to
    proceed...). The basic idea is to have a 'depressible' object, which can give you the
    illusion that you're 'pressing' it when you click it. The rollover effect causes
    something to h....
  15. Image Preloader With Progress Bar Status
    Pure Client-Side JavaScript tested in 4 Browsers! (28)
    Tutorial: Image Preloader with Progress Bar, by Rob J. Secord, B.Sc. (SystemWisdom)
    Description : A Tutorial for a Client-Side Image Preloader with Dynamic Real-Time Progress Bar
    Indicator written in JavaScript! Tested to work with 4 Major Internet Browsers: Firefox, MSIE,
    Netscape, Opera (Complete sample solution provided at end of tutorial, just put it on your
    web-server, add your images and go!) Intended Audience : Beginner to Intermediate Web
    Developers. Although this tutorial will cover some advanced aspects of JavaScript, I will try to
    explain it all ....
  16. Opening New Tabs With Javascript
    (1)
    I just spent a couple of hours trying to figure out how to open new tabs from a Firefox sidebar. I
    found lots of different suggestions but none worked. Well finally I found this and it works. var
    browser = top.document.getElementById("content"); var tab = browser.addTab("http://www.google.com");
    An even better way of doing it is through: const kWindowMediatorContractID =
    "@mozilla.org/appshell/window-mediator;1"; const kWindowMediatorIID =
    Components.interfaces.nsIWindowMediator; const kWindowMediator = Components.classes
    .getService(kWindowMediatorIID); var browserWi....

    1. Looking for lesser, javascript, features

Searching Video's for lesser, javascript, features
See Also,
advertisement


Lesser Known Useful Javascript Features

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com