Beginner JavaScript Tutorial – 26 – Object Initializers




Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts

Original source


29 responses to “Beginner JavaScript Tutorial – 26 – Object Initializers”

  1. If you want a little more technical information, here: This is also known as JavaScript Object Notation, or JSON. You can make .json files and use this object notation to store a lot of data. According to json.org, it's meant to be a lightweight format to exchange data and is a subset of the JavaScript programming language. You can use json data in other programming languages such as C++, C#, Python, etc. I personally have used it in Python with NHL.com as that is the format used with all NHL.com queries to obtain players stats and live scores. Python has add-on's that parse the JSON data for you and puts it into a list (it may even have a built in JSON parser, but I can't remember). So basically you can use it to exchange data between your different programs, it's quite handy.

  2. Guys
    is this the same?

    <script>
    function person(firstName, lastName, Age) {
    return {
    firstName: firstName,
    lastName: lastName,
    Age: Age
    }
    }

    var bucky = person("Bucky", "Robert", 24);
    var taylor = person("Taylor", "Swift", 20);

    document.write(bucky.firstName + " " + bucky.lastName + " Age: " + bucky.Age + "<br />");
    document.write(taylor.firstName + " " + taylor.lastName + " Age: " + taylor.Age);
    </script>

  3. Thanks!
    This is for you Bucky.
    <html>
    <head>
    <script type="text/javascript">
    person = {name:"We all"};
    function explore(love){
    this.love = love;
    }
    var we = new explore(" love Bucky");
    function loop(){
    var l = 1;
    do{
    document.write(l + ". " + person.name + we.love + "<br/>");
    l++;
    }while(l<21);
    }

    </script>
    </head>
    <body>
    <button onClick="loop();" >Explore</button>
    </body>
    </html>

  4. <html>
    <head>
    <script type="text/javascript">
    jon = {name: "John Doe", age: 21, height: "185cm"};
    taylor = {name: "Taylor Swift", age: 21};
    </script>
    </head>
    <body>
    <script type="text/javascript">
    document.write (jon.height);
    </script>
    </body>
    </html>

    I get undefined

  5. WOAH
    i was adding a new property for "food" and was typing out "chinese"
    exactly the same time that he said "what am i, chinese?"
    fucking matrix yo, what are the chances

Leave a Reply