Watch Our YouTube Channel
It is currently Mon Sep 25, 2017 9:52 am
 

All times are UTC



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Java Script Objects
PostPosted: Thu Sep 16, 2010 12:04 pm 
Offline

Joined: Wed Sep 08, 2010 2:26 pm
Posts: 53
Location: TUTICORIN
Following codings explains some important objects in Java Script

Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<
html>
<
head>
<
script type="text/javascript">
    var 
txt="Hello World";
    
document.write(txt.length+"<br>");
</script>
<script type="text/javascript">
     //String Object in Java Script
    
    document.write(txt.toUpperCase());
    document.write(txt.big()+"<br>");
    document.write(txt.small()+"<br>");
    document.write(txt.bold()+"<br>");
    document.write(txt.italics()+"<br>");
    document.write(txt.fontsize(7)+"<br>");
    document.write(txt.fontcolor("green")+"<br>");
    document.write("subscript"+txt.sub()+"<br>");
    document.write("superscript"+txt.sup()+"<br>");
    document.write("link"+txt.link("http://www.google.com")+"<br>");
    document.write(txt.blink()+"<br>"+"It will does not work in IE,CHROME,SAFARI");
    
    //how to search specified value within a string
    
    document.write(txt.match("Hello")+"<br>");
    document.write(txt.match("World")+"<br>");
    document.write(txt.match("world")+"<br>");
    document.write(txt.replace("World","sam")+"<br>");
    document.write(txt.indexOf("WORLD")+"<br>");
    document.write(txt.indexOf("Hello")+"<br>");
    document.write(txt.indexOf("d")+"<br>");
    
    //Date function in javascript
    
    var d=new Date();
    document.write(d+"<br>");
    document.write(d.getTime()+"Milliseconds since 1970/1/1"+"<br>");
    d.setFullYear(2010,0,16);
    document.write(d+"<br>");
    
    //Converting to universal Time
    document.write("OriginalTime"+d+"<br>");
    document.write("Universal TIme"+d.toUTCString()+"<br>");
    
    //It will return only display today as 6th day not display like thursday
    document.write(d.getDay()+"<br>");
    
    //How to display current day
    var d=new Date();
    var day=Array();
    day[0]="SUNDAY";
    day[1]="MONDAY";
    day[2]="TUESDAY";
    day[3]="WEDNESDAY";
    day[4]="THURSDAY";
    day[5]="FRIDAY";
    day[6]="SATUREDAY";
    document.write("Today is"+"<br>");
    document.write(day[d.getDay()]+"<br>");
    </script>
    
    //how to Display clock
    <script type="text/javascript">
    function displayclock()
    {
    var today=new Date();
    var h=today.getHours();
    var    m=today.getMinutes();
    var    s=today.getSeconds();
    m=checkTime(m);
    s=checkTime(s);
    document.getElementById('txt').innerHTML=h+":"+m+":"+s;
    t=setTimeout('displayclock()',500);
    }
    function checkTime(i)
    {
    if(i<10)
    {
    return i="0"+i;
    }
    return i;
    }
    </script>
    
    
    //set Year
    <script type="text/javascript">
    var date=new Date();
    var s=date.setFullYear(2010,8,16);
    document.write(s+"<br>");
    </script>
    
    //Compare Two dates
    <script type="text/javascript">
    var mydate=new Date();
    mydate.setFullYear(2010,0,14);
    var today=new Date();
    if(mydate>today)
    {
    alert('Today is before 14th january 2010');
    }
    else
    {
    alert('today is after 14th january 2010');
    }
    </script>
    
    //Array in Javascript
    <script type="text/javascript">
    var x;
    var name=new Array();
    name[0]="sam";
    name[1]="anand";
    name[2]="jeba";
    for(x in name)
    {
    document.write("<br>");
    document.write(name[x]);
    document.write("<br>");
    }
    </script>
    
    
    //JOIN TWO ARRAYS IN JAVASCRIPT
    <script type="text/javascript">
    var parents=["JAMES","BEULAH"];
    var children=["anand","jeevitha","grana","juliet","roselint"];
    var family=parents.concat(children);
    document.write("<br>");
    document.write(family);
    </script>
    
    //Join All Elements of the array
    <script type="text/javascript">
    var fruits=["mango","Apple","orange","Banana"];
    document.write("<br>");
    document.write(fruits.join()+"<br>");    
    document.write(fruits.join("+")+"<br>");
    document.write(fruits.join("and")+ "<br>");
    </script>
    
    
    //Remove All Elements of the array
    <script type="text/javascript">
    var fruits=["mango","Apple","orange","Banana"];
    document.write("<br>");
    document.write(fruits.pop()+"<br>");    
    document.write(fruits+"<br>");
    document.write(fruits.pop()+ "<br>");
    </script>
    
    
    //Rount function
    <script type="text/javascript">
    document.write("<br>");
    document.write(Math.round(0.40));
    document.write("<br>");
    document.write(Math.round(0.50));
    document.write("<br>");
    document.write(Math.round(-4.40));
    document.write("<br>");
    document.write(Math.round(5.10));
    </script>
    
    
    
    


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body onLoad="displayclock()" >
<div id="txt">
</div>

</body>
</html>



_________________
Thanks & Regards
Sam Anand J
QualityPoint Technologies
Tuticorin.


Top
 Profile  
Reply with quote  
 Post subject: Re: Java Script Objects
PostPosted: Fri Jun 17, 2016 8:00 am 
Offline

Joined: Fri Nov 13, 2015 3:56 am
Posts: 439
In JavaScript, an object is a standalone entity, with properties and type.

Compare it with a cup, for example. A cup is an object, with properties. A cup has a color, a design, weight, a material it is made of, etc.

The same way, JavaScript objects can have properties, which define their characteristics.

Properties of JavaScript objects can also be accessed or set using a bracket notation.

Objects are sometimes called associative arrays, since each property is associated with a string value that can be used to access it.

_________________
Learn Web Development | Latest Technology News |Motivational Quotes


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron