Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24

Thread: Element help

  1. #21
    Join Date
    Oct 2013
    Location
    Finland
    Posts
    52
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Thanks traq and now i have a question is it possible to add multiple
    Values on same variable on same function

  2. #22
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by NitroDev View Post
    Thanks traq and now i have a question is it possible to add multiple
    Values on same variable on same function
    I'm not quite sure what you mean by that.

    You can provide a new value each time you call a function:
    Code:
    var hello = function( name ){
        var greeting = "Hello, " + name + "!";
        return greeting;
    }
    
    hello( 'World' );  // Hello, World!
    hello( 'Adrian' );  // Hello, Adrian!
    hello( 'NitroDev' );  // Hello, NitroDev!
    Functions can also have more than one argument:
    Code:
    var add = function( num1, num2 ){
        var sum = num1 + num2;
        return sum;
    }
    
    add( 50,-8 );  // 42
    Functions can even have unnamed arguments (though this concept is a little more advanced, and is not always as useful as it seems):
    Code:
    var mystery = function(){
        var count = arguments.length;
        var response = "You passed " + count + " arguments to this function.";
        return response;
    }
    
    mystery( 'one arg' );  // You passed 1 arguments to this function.
    mystery( 'a','b','c' );  // You passed 3 arguments to this function.
    If you're asking something else, please explain further.

  3. #23
    Join Date
    Oct 2013
    Location
    Finland
    Posts
    52
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Okay i mean this

    Code:
    var example = hello, world
    So one variable stores multiple values

  4. #24
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Not exactly. You can use an array to store a list of values:
    Code:
    var myArray = [ 'hello', 'world' ];
    
    console.log( myArray[0] );  // hello
    console.log( myArray[1] );  // world
    Or, you can use a plain object to store a map of keys and values:
    Code:
    var myObject = { me: "Tarzan", you: "Jane" };
    
    console.log( myObject.me  );  // Tarzan
    console.log( myObject.you );  // Jane

Similar Threads

  1. Resolved Ajax loaded element not recognized in ajax post send(element)?
    By crobinson42 in forum JavaScript
    Replies: 6
    Last Post: 04-10-2012, 07:48 PM
  2. <a> element
    By d-machine in forum CSS
    Replies: 1
    Last Post: 10-06-2009, 03:10 PM
  3. Replies: 5
    Last Post: 11-19-2008, 04:02 AM
  4. Replies: 0
    Last Post: 01-13-2008, 05:24 PM
  5. Changing the first TR element to THEAD element
    By codeexploiter in forum JavaScript
    Replies: 3
    Last Post: 03-23-2007, 10:02 AM

Bookmarks

Posting Permissions

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