80 likes | 241 Views
javascript. A Simple Overview. Outline. Definition & Guidelines Special Characters Conversion of Variables Pass by Value Pass by Reference Websites. Definition & Guidelines. Javascript is a scripting language It does not have to complied like Java, C, or C++
E N D
javascript A Simple Overview
Outline • Definition & Guidelines • Special Characters • Conversion of Variables • Pass by Value • Pass by Reference • Websites
Definition & Guidelines • Javascript is a scripting language • It does not have to complied like Java, C, or C++ • It is usually embedded in html pages • Guidelines • It is Case Sensitive • White Space is ignored • A backslash (\) breaks up a line • Special Characters also use the backslash
Conversion of Varaibles • Number to a String • aString= aNumber+'' • aString = Math.PI+ '' • aString= aNumber.toString() • aString= (3.14).toString() • String to a Number • parseFloat('0.1e5') // 10000 • parseFloat('.5') // 0.5 • parseFloat('3.7lbs') // 3.7 • parseInt('23') // 23 • parseInt('100.55') // 100 • parseInt('025',10) // 25 • parseInt('22',8) // 18 (= 2*8 + 2)
Pass By Value • Value is passed in by value • Changes to avariable while in afunction does not change the variable outside the function function passValue(xValue) { // xValue=1 xValue = 5; // xValue=1 } varxValue = 1; alert(xValue); // xValue=1 passValue(xValue); alert(xValue); // xValue=1
Pass By Reference • An object is passed in by reference • object properties are accessible within the function so value of the object can be changed in the function function Aobject() { this.value = 10; } var x = new Aobject(); alert(x.value); // x.value = 10 function Editobject(Fobject) { Fobject.value = 12; } Editobject(x); alert(x.value); // x.value is now equal to 12
Websites • http://www.w3schools.com/js/ • http://www.javascripter.net/faq/