www.webdeveloper.com
Results 1 to 4 of 4

Thread: New in Javascript to know [text] meaning.

  1. #1
    Join Date
    Apr 2012
    Posts
    5

    New in Javascript to know [text] meaning.

    Hi,
    i am beginner in javascript and i am confused to know about the below syntax.
    please help me
    here 'getd' text is inside square bracket , wanna to know what is the meaning of this?
    var args = [getd];

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    this is just a piece of some code. var args is an array (a set of indexed elements) and getd looks like a function which gets these elements from somewhere
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Apr 2012
    Posts
    55
    Yes, to elaborate on the previous response, the square brackets can be used as shorthand to create an array. The following code is equivalent:

    PHP Code:
    var args = new Array();
    args[0] = getd 
    or

    PHP Code:
    var args = new Array();
    args.push(getd); 
    Creating the array with square brackets is referred to as "syntax sugar." It doesn't provide new functionality, but it makes creating arrays much easier.
    joi JavaScript Framework - the sunnier side of JavaScript.

  4. #4
    Join Date
    Apr 2012
    Posts
    5
    Thanks everyone

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles