Friday, 6 March 2015

Week 38: March 2 - 6 JavaScript 6!

Hi!

Yeah! We had been started typing in JavaScript 6. We've rushed typing the JavaScript 6 for the reward of having a plus 10 points in our quiz. So everyone of us wanted to get it but nobody got it because it was too long to type of.:( ]

Here are the examples:

 In JavaScript, almost "everything" is an object.
  • Booleans can be objects (or primitive data treated as objects)
  • Numbers can be objects (or primitive data treated as objects)
  • Strings can be objects (or primitive data treated as objects)
  • Dates are always objects
  • Maths are always objects
  • Regular expressions are always objects
  • Arrays are always objects
  • Functions are always objects
  • Objects are objects
In JavaScript, all values, except primitive values, are objects.
Primitive values are: strings ("John Doe"), numbers (3.14), true, false, null, and undefined.  

The Object() Constructor:

A constructor is a function that creates and initializes an object. JavaScript provides a special constructor function called Object() to build the object. The return value of the Object() constructor is assigned to a variable.
The variable contains a reference to the new object. The properties assigned to the object are not variables and are not defined with the var keyword.

Example 1:

This example demonstrates how to create an object:
<html>
<head>
<title>User-defined objects</title>
<script type="text/javascript">
var book = new Object();   // Create the object
    book.subject = "Perl"; // Assign properties to the object
    book.author  = "Mohtashim";
</script>
</head>
<body>
<script type="text/javascript">
   document.write("Book name is : " + book.subject + "<br>");
   document.write("Book author is : " + book.author + "<br>");
</script>
</body>
</html>


Taken from http://www.tutorialspoint.com/javascript/javascript_objects.htm.

signing off...

0 comments:

Post a Comment

// Posted by :Unknown // On :Friday, 6 March 2015

Hi!

Yeah! We had been started typing in JavaScript 6. We've rushed typing the JavaScript 6 for the reward of having a plus 10 points in our quiz. So everyone of us wanted to get it but nobody got it because it was too long to type of.:( ]

Here are the examples:

 In JavaScript, almost "everything" is an object.

  • Booleans can be objects (or primitive data treated as objects)
  • Numbers can be objects (or primitive data treated as objects)
  • Strings can be objects (or primitive data treated as objects)
  • Dates are always objects
  • Maths are always objects
  • Regular expressions are always objects
  • Arrays are always objects
  • Functions are always objects
  • Objects are objects
In JavaScript, all values, except primitive values, are objects.
Primitive values are: strings ("John Doe"), numbers (3.14), true, false, null, and undefined.  

The Object() Constructor:

A constructor is a function that creates and initializes an object. JavaScript provides a special constructor function called Object() to build the object. The return value of the Object() constructor is assigned to a variable.
The variable contains a reference to the new object. The properties assigned to the object are not variables and are not defined with the var keyword.

Example 1:

This example demonstrates how to create an object:
<html>
<head>
<title>User-defined objects</title>
<script type="text/javascript">
var book = new Object();   // Create the object
    book.subject = "Perl"; // Assign properties to the object
    book.author  = "Mohtashim";
</script>
</head>
<body>
<script type="text/javascript">
   document.write("Book name is : " + book.subject + "<br>");
   document.write("Book author is : " + book.author + "<br>");
</script>
</body>
</html>


Taken from http://www.tutorialspoint.com/javascript/javascript_objects.htm.

signing off...

Leave a Reply

Subscribe to Posts | Subscribe to Comments

 

Blog Template by YummyLolly.com - Header made with PS brushes by gvalkyrie.deviantart.com
Sponsored by Free Web Space