Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
--------------------
-----------------------------------------------------------------------------------
--------------------
-----------------------------------------------------------------------------------
--------------------
-----------------------------------------------------------------------------------
--------------------
<form name="ff">
<input type="button" name="bb" />
<form>
<script LANGUAGE="JavaScript">
for ( prop in ff.bb ) {
document.write ( "button(bb)." , prop , " = " , ff.bb[prop] , "<br />") ; }
</script>
-----------------------------------------------------------------------------------
--------------------
-----------------------------------------------------------------------------------
--------------------
<script>
=> internal => document.write(" ----- ");
</script>
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Syentax |
-----------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Variable |
------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Data Type |
-------------
// typeOf();
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| OutPut |
----------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| InPut |
---------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Operators |
-------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Logical Operators |
---------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| If Cases |
------------
=> if(condition) {
statements;
} else if(condition) {
statements;
} else if(condition) {
statements;
} else(condition) {
statements;
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Loop |
--------
Syntax
------
var i;
=> for(i = 0; i < 10; i++) {
console.log(i);
}
-----------------------------------------------------------------------------------
--------------------
=> while(condition) {
statements;
final expression
}
EX
--
var i;
=> while(i < 10) {
console.log(i);
i++
}
-----------------------------------------------------------------------------------
--------------------
=> do {
statements;
final expression
} while(condition);
EX
--
var i;
=> do {
console.log(i);
i++
} while(i < 10);
-----------------------------------------------------------------------------------
--------------------
// Loop Controler :
=> break; =>
=> continue; =>
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Function |
------------
"use strict";
statements;
retern -----;
};
// Types of Function :
=> Built-in => " ready to use "
=> Custom Fanction => " which you defined it "
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Events |
----------
-----------------------------------------------------------------------------------
--------------------
-----------------------------------------------------------------------------------
--------------------
=> document.getElementById('btn');.onclick = function() {
"use strict";
x.style.color = "red";
}
-----------------------------------------------------------------------------------
--------------------
=> function change() {
"use strict";
document.getElementById('te').style.color = "red";
}
document.getElementById('btn');.onclick = change;
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Switch |
----------
EX :
----
switch(season)
case "winter":
alert("winter is too cold");
break;
case "summer":
alert("summer is too cold");
break;
case "autumn":
case "spring":
alert("this season is amazing");
break;
default:
alert("you didn't enter a season name");
break;
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Array |
---------
Litral Way
----------
=> var friends = ["sabry", "ahmed", "mostafa", "omar", "yasser"];
Constractor Way
----------------
// array check :
=>if(array.isArray(friend)) {
console.log("good this is array");
} else {
console.log("no this isn't array");
}
// length : var dem = "java script";
// remove elements :
=> length => firends[length] = "sayed";
- in last => pop(); => firends.pop("ali", "khaled", "ramadan",.... );
- in first => shift(); => firends.shift("ali", "khaled", "ramadan",.... );
- by index => splice(); => firends.splice(index, how many remove, add item 1,
add item 2, ...);
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Strings Methods |
-------------------
=> toString();
=> indexOf(value, start postion-d=0);
=> lastIndexOf(value, end postion-d=0);
=> search();
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Object |
----------
=> var myCar = {
color: red,
type: via,
price: 50.000,
module: 2017
}
console.log(myCar.type);
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Math |
--------
=> Math.ceil();
=> Math.floor();
=> Math.round();
=> Math.min();
=> Math.max();
=> Math.random(); => from 0 to 1
=> Math.pow(x,y); => x^y
=> Math.sqrt(); => root
=> Math.abs(); => abslute value
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
attributes list
=>
=>
=>
=>
// without double qoutes
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Date |
--------
// Date Format :
=> full format => new Date("");
=> long format => new Date("");
=> short format => new Date("M/D/Y HH:MM:DD");
=> ISO format => new Date("YYYY-MM-DD HH:MM:SS TZD"); =>
# used #
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Incrment & discrment |
------------------------
i++ => i = i + 1
i-- => i = i - 1
i += x => i = i + x
i -= x => i = i - x
i *= x => i = i * x
i /= x => i = i / x
i %= x => i = i % x
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Window Method |
-----------------
=> window.#anything
=> /n
=> prompt("text", "example value");
=> alert();
=> confirm(); => boolean value(true , false )
=> setTimeOut(function, milesecond, param1, param2, ......);
=> clearTimeOut(myTime);
=> var myInterval = setInterval(function, milesecond, param1, param2, ......);
=> clearSetInterval(myInterval);
=> window.open(url, target, spacification, history replace);
=> scrollBy(x, y); => =,-
=> scrollTo(x, y); => =,-
=> stop();
=> .close();
=> .foucus();
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Window Proprites |
--------------------
=> .innerHeight();
=> .innerWidth();
=> .outterHeight();
=> .outterWidth();
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| |
-----------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| |
-----------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
=> document.getElementById('...');
=> document.getElementsByTagName('...');
=> document.getElementsByClassName('...');
=> document.quarySelectorAll('...');
=> document.quarySelector('...');
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
Colactions
| Find Elements by Object |
---------------------------
=> document.title
=> document.body
=> document.images
=> document.forms
=> document.links
=> document.anchors
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Class List |
--------------
=> .classList();
=> .classList.lenght;
=> .classList.contains('class1', 'class2', .....);
=> .classList.items(class index);
=> .classList.add('class1', 'class2', .....); || .classList += "'class1',
'class2', .....";
=> .classList.remove('class1', 'class2', .....); || .classList -= "'class1',
'class2', .....";
=> .classList.toggle('class1', 'class2', .....);
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Child | child = "HTML tags only"
---------
=> .children;
=> .children(child index);
=> .children.length; || .childElementCount;
=> .firstElementChild;
=> .lastElementChild;
=> .appendChild();
=> .createElement();
=> .createTextNode();
=> .createComment();
// create attribute
.createAttribute(/*attributeName*/);
/*attributeName*/.value = " ";
/*element*/.setAttributeNode(/*attributeName*/);
EX :
----
myNewEement = document.createElement('div'),
// create p element
myNewP = document.createElement('p'),
myNewEement.appendChild(myText);
myMainDiv.appendChild(myNewEement);
myMainDiv.appendChild(myNewP);
=> .tagName;
=> .nextElementSibiling;
=> .previousElementSibiling;
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
=> .childNodes;
=> .childNodes(child index);
=> .childNodes.length;
=> .firstChild;
=> .lasttChild;
=> .nodeName;
=> .nodeName;
=> .nextSibiling;
=> .previousSibiling;
// .cloneNode(); = .cloneNode(false);
// .cloneNode(); => clone tag and his attributes without his content (text)
// .cloneNode(false); => clone tag && his attributes without his content (text)
// .cloneNode(true); => clone tag && his attributes && his content (text)
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| Callback Function |
---------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
| |
-----------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
=> .focus;
=> .blur;
=> this.
=> document.inputEncoding;
=> document.lastModified;
=> document.URL;
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------------------------------------