Uploaded by Арман Алимханов

javascriptpdf-221116015849-86c43fe5

advertisement
CHEAT SHEET
JavaScript in an HTML Page
<script type="text/javascript">
//JS code goes here
Call an External JavaScript
File
<script src="myscript.js">
</script>
</script>
Go to website
Including Comments
Single-line comments: //
Multi-line comments : /* and */
Go to website
Go to website
Variables
var
const
let
Go to website
Design by anythingprogramming.com
Data Types
strings
numbers
booleans
undefined
ull.
Go to website
Arrays
var fruit = [
"Banana",
"Apple",
"Pear"];
OR
var fruit = ["Banana", "Apple",
"Pear"];
Go to website
Objects
var person = {
firstName:"John",
lastName:"Doe",
age:20,
nationality:"German"
};
Go to website
Array Methods
concat()
indexOf()
join()
lastIndexOf()
pop()
push()
reverse()
shift()
slice()
sort()
splice()
toString()
unshift()
valueOf()
Go to website
Design by anythingprogramming.com
Operators
Operators
Basic Operators
Basic Operators
+ — Addition
- — Subtraction
* — Multiplication
/ — Division
(...) — Grouping operator,
% — Modulus (remainder )
++ — Increment numbers
-- — Decrement numbers
Go to website
Go to website
Operators
Comparison Operators
== — Equal to
=== — Equal value and equal type
!= — Not equal
!== — Not equal value or not equal type
> — Greater than
< — Less than
>= — Greater than or equal to
<= — Less than or equal to
? — Ternary operator
Go to website
Operators
Logical Operators
&& — Logical and
|| — Logical or
! — Logical not
Go to website
Design by anythingprogramming.com
Operators
Bitwise Operators
& — AND statement
| — OR statement
~ — NOT
^ — XOR
<< — Left shift
>> — Right shift
>>> — Zero fill right shift
Outputting Data
alert()
confirm()
console.log()
document.write()
prompt()
Functions
function name(parameter1, parameter2,
parameter3) {
// what the function does
}
Global Functions
decodeURI()
decodeURIComponent()
encodeURI()
encodeURIComponent()
eval()
isFinite()
isNaN()
Design by anythingprogramming.com
Loops
For
While
Do While
Break
Continue
Strings
Escape Characters
\' — Single quote
\" — Double quote
\\ — Backslash
\b — Backspace
\f — Form feed
Conditional Statement
If Statement
If...Else Statement
Switch Case**
Strings
Escape Characters
\n — New line
\r — Carriage return
\t — Horizontal tabulator
\v — Vertical tabulator
Design by anythingprogramming.com
String Methods
charAt()
charCodeAt()
concat()
fromCharCode()
indexOf()
lastIndexOf()
match()
replace()
Numbers
Number Properties
MAX_VALUE
MIN_VALUE
NaN
NEGATIVE_INFINITY
POSITIVE_INFINITY
String Methods
search()
Slice()
Split()
substr()
substring()
toLowerCase()
toUpperCase()
Numbers
Number Methods
toExponential()
toFixed()
toPrecision()
toString()
valueOf()
Design by anythingprogramming.com
Pulling Date and Time
Values
getDate())
getDay()
getFullYear()
getHours()
getMilliseconds()
getMinutes()
getMonth()
Set Part of a Date
setDate()
setFullYear()
setHours()
setMilliseconds()
setMinutes()
setMonth()
setSeconds()
setTime
Pulling Date and Time
Values
getSeconds()
getTime()
getUTCDate()
parse()
DOM
DOM Properties
attributes()
baseURI()
childNodes()
firstChild()
lastChildnext()
Siblingnode()
Namenode()
Design by anythingprogramming.com
DOM
DOM Methods
appendChild()
cloneNode()
compareDocumentPosition()
getFeature()
hasAttributes()
hasChildNodes()
insertBefore()
DOM
Element Methods
getAttribute()
getAttributeNS()
getAttributeNode()
getAttributeNodeNS()
getElementsByTagName()
DOM
DOM Methods
isDefaultNamespace()
isEqualNode()
isSameNode()
isSupported()
lookupNamespaceURI()
lookupPrefix()
normalize()
DOM
Element Methods
getElementsByTagNameNS()
hasAttribute()
hasAttributeNS()
removeAttribute()
removeAttributeNS()
removeAttributeNod()
esetAttribute()
Design by anythingprogramming.com
Window Properties
closed()
defaultStatus()
document()
frames()
history()
innerHeight()
innerWidth()
Events
Mouse Event
onclick()
oncontextmenu()
ondblclick()
onmousedown()
onmouseenter()
onmouseleave()
onmousemove()
onmouseover()
Window Methods
alert()
blur()
clear Interval()
clear Timeout()
confirm()
focus()
moveBy()
moveToprint()
Events
Keyboard Event
onkeydown()
onkeypress()
onkeyup()
Design by anythingprogramming.com
Frame
onabort
onbeforeunload
onerror
onhashchange
onload
onpagehide
onpageshow
onscroll
Media
onabort
oncanplay
oncanplaythrough
ondurationchange
onended
onerror
onloadeddata
Form
onblur
onchange
onfocus
onfocusin
onfocusout
oninput
oninvalid
onreset
onsearch
Animation
animationend
animationiteration
animationstart
Design by anythingprogramming.com
Errors
try
catch
throw
finally
Others
onstorage
ontoggle
onwheel
ontouchcancel
ontouchend
ontouchmoveo
ntouchstart
Others
transitionend
onmessage
onoffline
ononline
onpopstate
onshow
Others
EvalError
RangeError
ReferenceError
SyntaxError
TypeError
URIError
Design by anythingprogramming.com
Visit our Webpage for
more cheats
https://www.anythingprogramming.com
Download