Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,959
    Thanks
    120
    Thanked 76 Times in 76 Posts

    Some clarifications needed

    This is working code, need some explanations how to read it ...
    Code:
     var e, t, n = this;
        for (e in this.mapData.paths)'1't = this.canvas.addPath
        (
            {
            '2'd: this.mapData.paths[e].path,"data-code": e
    
    ....
    Red things inserted by me.

    1. should not there be '{' ?
    And since it is not what is all that doing ?

    2. how to read that entire line, what are ":" doing ?
    Last edited by BubikolRamios; 12-30-2013 at 01:17 AM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    966
    Thanks
    19
    Thanked 211 Times in 209 Posts
    Well as for number two ...

    Code:
     
      <script>
    function displayPropertyValues(object){
     for(property in object)
      alert(property+" = "+object[property]);
    }
    displayPropertyValues({one:1,two:2}) 
    </script>
    
    {} creates an object
    {one:1,two:2} creates an object and
    adds properties and sets their values
    it is called an object literal
    Last edited by DaveyErwin; 12-30-2013 at 03:00 AM.

  • #3
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,959
    Thanks
    120
    Thanked 76 Times in 76 Posts
    OK, but then as for 2

    Code:
    d: this.mapData.paths[e].path,"data-code": e
    This looks strange tome, should be then without " ?
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,589
    Thanks
    0
    Thanked 644 Times in 634 Posts
    Quote Originally Posted by BubikolRamios View Post
    OK, but then as for 2

    Code:
    d: this.mapData.paths[e].path,"data-code": e
    This looks strange tome, should be then without " ?
    The " are optional where the property name complies with the standards for naming variables - that is it starts with a letter, _ or $ and only contains letters, numbers _ and $ but the " can always be included when using that notation. They are mandatory if passing data that way between the browser and the server.

    With your first query the {} are not needed when they only contain a single statement. It is still better to put them there though.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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