Thursday 25 May 2017

...Family...

👆🏻

Unnodu Vaazhntha Kaalangal  Yaavum Kanavaai Ennai Mooduthadi 

Nerupaalum Mudiyathamma Ninaivugalai Azhipatharku Unnakaga Kathirpen💗😭🤡

Wednesday 10 May 2017

string method

https://www.w3schools.com/js/js_string_methods.asp

String Object

<!DOCTYPE html>
<html>
<body>

<h2>Never Create Strings as objects.</h2>
<p>Strings and objects cannot be safely compared.</p>

<p id="demo1"></p>
<p id="demo2"></p>
<p id="demo3"></p>
<p id="demo4"></p>
<p id="demo5"></p>

<script>
var x = "John";              // x is a string
var y = new String("John");  // y is an object
document.getElementById("demo1").innerHTML = (x==y)+'<br>becz equal value';


var x = "John";              // x is a string
var y = new String("John");  // y is an object
document.getElementById("demo2").innerHTML = (x===y)+'<br>not equal becz one is string anothe is object';



var x = new String("John");            
var y = new String("John");
document.getElementById("demo3").innerHTML = (x==y)+'<br>different object';

document.getElementById("demo4").innerHTML = "Hello" +
"Dolly!";

</script>

</body>
</html>

js variable

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript typeof</h2>
<p>The typeof operator returns the type of a variable or an expression.</p>

<p id="demo"></p>

<script>
var a="hai";
var b=4;
var c;
var d=null;
document.getElementById("demo").innerHTML =
typeof a +'     a=hai'+'<br>'+
typeof d +'     d=null is treated as object'+'<br>'+
typeof b +'    b=4'+'<br>'+ typeof c +'   just var c'+'<br>'+
 typeof true +'    typeof true'+'<br>'+
 typeof [1,2,3,4] +'    typeof [1,2,3,4]  '+'<br>'+
typeof {name:'john', age:34} + '<br>'+
typeof function myFunc(){}+'         typeof function myFunc(){}   '+'<br>'+
(null === undefined) + "<br>" +
(null == undefined);
</script>

</body>
</html>
<!--
10 == Equal x == y
10 === Strict equal x === y
10 != Unequal x != y
10 !== Strict unequal x !== y

 -->

js variable

<!DOCTYPE html>
<html>
<body>


<!--
vist this site for artimetic options
https://www.w3schools.com/js/js_arithmetic.asp


vist this site for assignment of operators
https://www.w3schools.com/js/js_assignment.asp
 -->



<h2>JavaScript Variables</h2>

<p>The result of adding 2 + 3 </p>
<p id="demo1a"></p>
<p>just declearing the var y; then print y it will display as undefined</p>

<p id="demo1b"></p>


<p>The result of adding "5"+ 2 + 3    if first oprand to be added as string then treat all the following oprand as string</p>

<p id="demo2"></p>


<p>The result of adding 2 + 3 + "5":</p>

<p id="demo3"></p>


<p>string concatination methode 1</p>

<p id="demo4"></p>



<p>string concatination methode 2</p>

<p id="demo5"></p>

<p>string concatination methode 3</p>

<p id="demo6"></p>

<script>
var x =  2 + 3 ;
var y;
document.getElementById("demo1a").innerHTML = x;
document.getElementById("demo1b").innerHTML = y;


var x =  "5"+ 2 + 3 ;
document.getElementById("demo2").innerHTML = x;

var x =  2 + 3 +"5" ;
document.getElementById("demo3").innerHTML = x;

var fn="vishnu"+" "+"yardini";
document.getElementById("demo4").innerHTML=fn;

var fn="vishnu",ln="yardini";
document.getElementById("demo5").innerHTML=fn+" " + ln;

var txt1 = "What a very ";
txt1 += "nice day";
document.getElementById("demo6").innerHTML = txt1;

</script>

</body>
</html>


js statement

<html>
<head>
<script>
function myFunction1()
{ var a=10;
var b=20;
var c=a+b;
document.getElementById("para2").innerHTML=c;
}

function myFunction2()
{
document.getElementById("para3").innerHTML="this is for para 3 after change belong to same function";
document.getElementById("para4").innerHTML="this is for para 4 after change belong to same function";

}


</script>
</head>
<body>
<p id='para1'>this is the para 1 b4 change</p>
<button type='button' onClick="document.getElementById('para1').innerHTML='para 1 after change'"> para 1 </button>


<p id='para2'>this is the para 2 b4 change</p>
<button type='button' onClick='myFunction1()'> para 2 </button>


<p id='para3'>this is the para 3 b4 change</p>
<button type='button' onClick="myFunction2()"> para 3 </button>


<p id='para4'>this is the para 4 b4 change</p>
<button type='button' onClick="myFunction2()"> para 4</button>


</body>
</html>

js in head

<html>
<head>
<script>
function myFunction()
{
document.getElementById("para").innerHTML="this is not para";
}
</script>
</head>
<body>
<p id='para'> hai this is para </p>
<button type="button" onClick="myFunction()">click on me </button>
</body>
</html>

js as external file

<!DOCTYPE html>
<html>
<body>

<h2>External JavaScript</h2>

<p id="para">A Paragraph.</p>

<button type="button" onclick="myFunction()">Try it</button>

<p>(myFunction is stored in an external file called "myScript.js")</p>

<script src="xjs.js"></script>

</body>
</html>
v

js in body tag

<html>

<body>
<p id=para> hai this is para </p>
<button type="button" onClick="myFunction()">click on me </button>


<script>
function myFunction()
{
document.getElementById("para").innerHTML="this is not para";
}
</script>


</body>
</html>

js event

<html>
<body>
<p id='para'>no will display here</p>
<button onClick="document.getElementById('para').innerHTML=Date()">click here to c the time below line</button>

<br>
<br>
<p> In the bellow button it seld display the time by clicking it<br><br>that is button contain time</p>
<button onClick="this.innerHTML=Date()">time is?</button>


<p>here <b>onclick</b> is the event to know more about event
<a href='https://www.w3schools.com/jsref/dom_obj_event.asp'>click here to know about events</a></p>

</body>
</html>

image colour change

<html>

<title>colour change </title>

<body>

<h2>What Can JavaScript Do?</h2>

<p id="demo">JavaScript can change HTML content.</p>


<button  onclick="document.getElementById('myimage').src='C:/Users/abc/Documents/js/image/pic_bulboff.gif'">trun off</button>


<img id="myimage" src='C:/Users/abc/Documents/js/image/pic_bulboff.gif' style="width:200px">

<button  onclick="document.getElementById('myimage').src='C:/Users/abc/Documents/js/image/pic_bulbon.gif'">trun on</button>


</body>
</html>

functions

<html>
<body>
<p id='demo'></p>
<script>


document.getElementById('demo').innerHTML = addtion(1,2);

function addtion(add1,add2)
{
return add1+add2;
}
</script>


</body>
</html>

different output methode

<!DOCTYPE html>
<html>
<body>

<script>
window.alert(5+6,"this is alert window");
console.log(5 + 6);
document.write("this is document wite",9+9);

</script>

<p id="para"> this is para</p>
<button type="button" onClick='document.getElementById("para").innerHTML="hai changed"'>click here</button>

<p id="paraDoc">this text is replace by document write</p>
<button type="button" onClick='document.write("it will delete all html elements that can be know by inpecting the page") '>click here document write button</button>


</body>
</html>

Data Types


<html>
<body>
<p id='demo1'></p>
<p id='demo2'></p>
<p id='demo3'></p>
<p id='demo4'></p>
<p id='demo5'></p>
<p id='demo6'></p>

<script>
var a=123e5;
document.getElementById('demo1').innerHTML=a+'it is the value of 123e5';

var b=123e-5;
document.getElementById('demo2').innerHTML=b +'it is the value of 123e-5';

var c=true
document.getElementById('demo3').innerHTML=c+'  this the boolean value c=true'


var car=[1,2,"bmw","vento"];
document.getElementById('demo4').innerHTML='  this is array 1st val   ' + car[0] +"<br>"+' this is sec val   '+car[3];


var person = {fn:'vishnu',ln:'falthoos',age:21};

document.getElementById('demo5').innerHTML=person.fn+'    this is the first object'+'<br><br>'+;


</script>
</body>
</html>

button click test size change

<!DOCTYPE html>
<html>

<body>

<h2>What Can JavaScript Do?</h2>

<p id="demo">JavaScript can change HTML content.</p>

<button type="button"
onclick="document.getElementById('demo').style.fontSize='35px'">
Click Me!
</button>

</body>
</html>

button click text change

<!DOCTYPE html>
<html>
<!-- <script src="https://www.w3schools.com/lib/w3.js"></script> -->
<body>

<h2>What Can JavaScript Do?</h2>

<p id="demo">JavaScript can change HTML content.</p>

<button type="button" onclick='document.getElementById("demo").innerHTML = "Hello JavaScript!"'>Click Me!</button>

</body>
</html>

Thursday 4 May 2017

Image colour change

<html>

<title>colour change </title>

<body>

<h2>What Can JavaScript Do?</h2>

<p id="demo">JavaScript can change HTML content.</p>


<button  onclick="document.getElementById('myimage').src='C:/Users/abc/Documents/js/image/pic_bulboff.gif'">trun off</button>


<img id="myimage" src='C:/Users/abc/Documents/js/image/pic_bulboff.gif' style="width:200px">

<button  onclick="document.getElementById('myimage').src='C:/Users/abc/Documents/js/image/pic_bulbon.gif'">trun on</button>


</body>
</html>






REPL stands for Read Eval Print Loop

Starting REPL


$ node

$ node
>

Simple Expression


$ node
> 1 + 3
4
> 1 + ( 2 * 3 ) - 4
3
>

Use Variables

You can make use variables to store values and print later like any conventional script. If var keyword is not used, then the value is stored in the variable and printed. Whereas if var keyword is used, then the value is stored but not printed. You can print variables using console.log().
$ node
> x = 10
10
> var y = 10
undefined
> x + y
20
> console.log("Hello World")
Hello Workd
undefined

Multiline Expression

$ node
> var x = 0
undefined
> do {
... x++;
... console.log("x: " + x);
... } while ( x < 5 );
x: 1
x: 2
x: 3
x: 4
x: 5
undefined
>
... comes automatically when you press Enter after the opening bracket. Node automatically checks the continuity of expressions.

Underscore Variable

You can use underscore (_) to get the last result −
$ node
> var x = 10
undefined
> var y = 20
undefined
> x + y
30
> var sum = _
undefined
> console.log(sum)
30
undefined
>

REPL Commands

  • ctrl + c − terminate the current command.
  • ctrl + c twice − terminate the Node REPL.
  • ctrl + d − terminate the Node REPL.
  • Up/Down Keys − see command history and modify previous commands.
  • tab Keys − list of current commands.
  • .help − list of all commands.
  • .break − exit from multiline expression.
  • .clear − exit from multiline expression.
  • .save filename − save the current Node REPL session to a file.
  • .load filename − load file content in current Node REPL session.

Stopping REPL.


$ node
>
(^C again to quit)
>