Friday, 23 January 2015

Week 32: Jan.19-23 Exercises!

Hi!


      We don't  have class in our ICT Class on Monday and Tuesday.  On wednesday, I've  finished my exercise 2 and 3. While on friday, I had finished my exercise 4.  But I did'nt know how to make the exercise 5. I tried my best.

 
      Here are examples.







    Number() converts to a Number, String() converts to a String, Boolean() converts to a Boolean.

JavaScript Data Types

In JavaScript there are 5 different data types that can contain values:
  • string
  • number
  • boolean
  • object
  • function
There are 3 types of objects:
  • Object
  • Date
  • Array
And 2 data types that cannot contain values:
  • null
  • undefined

The typeof Operator

You can use the typeof operator to find the data type of a JavaScript variable.

Example

typeof "John"                 // Returns string typeof 3.14                   // Returns numbertypeof NaN                    // Returns numbertypeof false                  // Returns booleantypeof [1,2,3,4]              // Returns objecttypeof {name:'John', age:34}  // Returns objecttypeof new Date()             // Returns objecttypeof function () {}         // Returns functiontypeof myCar                  // Returns undefined (if myCar is not declared)typeof null                   // Returns object
Please observe:
  • The data type of NaN is number
  • The data type of an array is object
  • The data type of a date is object
  • The data type of null is object
  • The data type of an undefined variable is undefined
You cannot use typeof to define if an object is an JavaScript Array or a JavaScript Date.

Taken from http://www.w3schools.com/js/js_type_conversion.asp.
signing off...

0 comments:

Post a Comment

// Posted by :Unknown // On :Friday, 23 January 2015

Hi!


      We don't  have class in our ICT Class on Monday and Tuesday.  On wednesday, I've  finished my exercise 2 and 3. While on friday, I had finished my exercise 4.  But I did'nt know how to make the exercise 5. I tried my best.

 
      Here are examples.







    Number() converts to a Number, String() converts to a String, Boolean() converts to a Boolean.

JavaScript Data Types

In JavaScript there are 5 different data types that can contain values:
  • string
  • number
  • boolean
  • object
  • function
There are 3 types of objects:
  • Object
  • Date
  • Array
And 2 data types that cannot contain values:
  • null
  • undefined

The typeof Operator

You can use the typeof operator to find the data type of a JavaScript variable.

Example

typeof "John"                 // Returns string typeof 3.14                   // Returns numbertypeof NaN                    // Returns numbertypeof false                  // Returns booleantypeof [1,2,3,4]              // Returns objecttypeof {name:'John', age:34}  // Returns objecttypeof new Date()             // Returns objecttypeof function () {}         // Returns functiontypeof myCar                  // Returns undefined (if myCar is not declared)typeof null                   // Returns object
Please observe:
  • The data type of NaN is number
  • The data type of an array is object
  • The data type of a date is object
  • The data type of null is object
  • The data type of an undefined variable is undefined
You cannot use typeof to define if an object is an JavaScript Array or a JavaScript Date.

Taken from http://www.w3schools.com/js/js_type_conversion.asp.
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